android - ListView OnItemClickListener doesn't fire -
i'm @ loss. have listview being set via adapter in fragment.
public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { view view = inflater.inflate(r.layout.fragment_knowledgebase, container, false); // set adapter mlistview = (abslistview) view.findviewbyid(r.id.searchresultlist); // set onitemclicklistener can notified on item clicks mlistview.setonitemclicklistener(this); mlistview.setadapter(madapter); return view; } public void onitemclick(adapterview<?> parent, view view, int position, long id) { if (null != mcallback) { //call activity mcallback.onfragmentinteraction(position); } }
the layout of list dead simple. 1 text view, no buttons or check boxes.
<framelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent"> <listview android:id="@+id/searchresultlist" android:layout_width="match_parent" android:layout_height="match_parent" android:footerdividersenabled="true" android:clickable="true" /> <textview android:id="@+id/name" android:layout_width="match_parent" android:layout_height="40dp" android:gravity="start" android:focusable="false" android:focusableintouchmode="false" android:clickable="false" android:textisselectable="false"/>
i've set focusable properties false , still no dice
the main problem variable mcallback
null. code below not triggering...
public void onitemclick(adapterview<?> parent, view view, int position, long id) { if (null != mcallback) { //call activity mcallback.onfragmentinteraction(position); } }
this
if (null != null) {
to check answer, try this:
public void onitemclick(adapterview<?> parent, view view, int position, long id) { log.e("listview onitemclick","clicked"); if (null != mcallback) { //call activity mcallback.onfragmentinteraction(position); } }
this log listview onitemclick clicked
Comments
Post a Comment