Domanda

I am creating a customlistview which contains buttons and edittext and textview. I have added onclicklistener to the buttons. also I want the itemclicklistener of listview should work. the buttons are for changing the value inside the edittext. and onitemclicklistener is for sending data to next activity. But when I add onclicklistener to button the itemclicklistener of the listview does not work. I have tried changing buttons to imageview still it doesnt work.Also I tried adding property focusable="false" for button but the activity gets forced close when focusable="false" is added.

help me to achieve this. thanks in advance.

È stato utile?

Soluzione

If any row item of list contains Focusable or Clickable view then OnItemClickListener won't work. Check descendantFocusability.

row item must be having param like

android:descendantFocusability="blocksDescendants"

Add this line in your list_item.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:baselineAligned="false"
android:descendantFocusability="blocksDescendants"
android:gravity="center_vertical" >

// your other Button and Other widget here

</LinearLayout>
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top