I can't click the ListView in android?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-03 13:26:41

in nested Views, the child view always gets all the touch events first. if you want the parent view (in your case, the listView row), to get a touch event, you must return false on the child events or set them to be android:clickable="false" in the manifest.

add

 android:focusable="false"  

and

 android:clickable="false"

for each child view like imageview,textview,checkbox etc... of your row layout means in manage_track_list_custom_view.xml

I think you have to set all your clickable things eg. checkboxes, buttons etc. as not focusable(in the adapter class).

        holder.yourButton.setFocusable(false);
        holder.yourButton.setFocusableInTouchMode(false);

        holder.yourCheckbox.setFocusable(false);
        holder.yourCheckbox.setFocusableInTouchMode(false);

Try this:

When you add the listView, call

setDescendantFocusability(FOCUS_BLOCK_DESCENDANTS);

Have a look here for more info.

You can set onclick listner to the View row in ContactListAdapter class.

    holder.check.setChecked(objects[position].isSelected());    
       row.setOnclickListner(new Onclicklistner(){
          // Your code here
       });
    return row;

I have same problem when I can't click on other part of an item in list view, just can click in textview or imageview inside that item. So I set my textview:

android:layout_width="fill_parent"

my item like this:

<relative>
[image][textview]
relative/>

And clicking event worked fine because I click on the textview. Hope will help anyone has same problem.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!