Skip to content Skip to sidebar Skip to footer

Onitemclick Not Responding To Clicks

have searched listview OnClick not working pages, doesn't solve. my Activity populates listview by calling a custom adapter MyArrayAddapter which extends ArrayAdapter class. Th

Solution 1:

Edit:

Replace your row xml file with this

<?xml version="1.0" encoding="utf-8"?><RelativeLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"android:descendantFocusability="true"android:padding="20dp"
      ><TextViewandroid:id="@+id/tvrow"android:layout_width="fill_parent"android:layout_height="wrap_content"android:text="Component" /><LinearLayoutandroid:weightSum="9"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_below="@id/tvrow"   ><Buttonandroid:id="@+id/bL"android:layout_weight="4"android:layout_width="wrap_content"android:layout_height="wrap_content"android:focusable="false"android:background="@drawable/blue_right"        
         /><Buttonandroid:id="@+id/bC"android:layout_weight="1"android:focusable="false"android:layout_width="wrap_content"android:layout_height="wrap_content"android:background="@drawable/component2"
         /><Buttonandroid:layout_weight="4"android:id="@+id/bR"android:focusable="false"android:layout_width="wrap_content"android:layout_height="wrap_content"android:background="@drawable/blue_right"
        /></LinearLayout></RelativeLayout>

Your custom adapter may have a focusable items like (EditText, Button) etc, try to set focus of row items to false

Solution 2:

 listView.performClick();

Would trigger onClick() on the listview and not on individual items in the list.

So, you should also have to implement the onClick() method to intercept clicks on your listview.

Post a Comment for "Onitemclick Not Responding To Clicks"