Reputation: 313
I'm using custom layout for list item of listView
that named row.xml
This is my row.xml
file:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:orientation="vertical"
android:descendantFocusability="afterDescendants" >
<TextView
android:id="@+id/label"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:gravity="right"
android:textSize="40sp"
android:focusableInTouchMode="false"
android:clickable="false"
android:focusable="false" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="right|center"
android:orientation="horizontal">
<Button
android:id="@+id/delete_btn"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginRight="5dp"
android:gravity="right|center"
android:text="delete" />
</LinearLayout>
</LinearLayout>
With the above layout, onListItemClick()
method not working,but when i remove the Button
element from layout, it's working correctly.
Please let me to know what's the problem
Thanks
Upvotes: 3
Views: 325
Reputation: 313
By "Raghunandan" 's help, i'm add
android:focusable="false"
android:focusableInTouchMode="false"
to Button
,and my problem solved
The Button
gain focus over the row, that's why we can't select the row
Upvotes: 1