문제

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.

도움이 되었습니까?

해결책

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>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top