android - ImageButton in Linear Layout not clicked. Setting Listener from service -
this different other post of nature because in service cannot name onclicklistener
through xml have programatically.
i have imagebutton
in xml file (it @ bottom):
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <horizontalscrollview> ... </horizontalscrollview> <view android:layout_width="match_parent" android:layout_height="3dp" android:background="@color/light_grey" /> <framelayout> ... </framelayout> <view android:layout_width="match_parent" android:layout_height="3dp" android:background="@color/light_grey" /> <linearlayout android:layout_width="match_parent" android:layout_height="50dp" android:orientation="horizontal" android:weightsum="3"> <imagebutton android:id="@+id/deletebutton" android:layout_width="0dp" android:contentdescription="delete button" android:focusable="false" android:layout_height="50dp" android:clickable="true" android:background="@drawable/simplerect" android:src="@drawable/deletebtn24dp" android:layout_weight="1"/> </linearlayout>
i set onclicklistener
in service this:
imagebutton deletebtn = (imagebutton) mainkeyboard.findviewbyid(r.id.deletebutton); deletebtn.setonclicklistener(new android.view.view.onclicklistener() { public void onclick(view view1) { log.i("debug_tag","button being clicked"); getcurrentinputconnection().setcomposingtext("",1); getcurrentinputconnection().deletesurroundingtext(10000,10000); } });
however onclicklistener
not being called. i'm not sure do, since way can set listener because doing service , not activity
it turned out needed add following attribute linear layout
contained button:
android:descendantfocusability="blocksdescendants"
Comments
Post a Comment