Unable to get listView.ItemClick to be called in MonoDroid

后端 未结 3 531
日久生厌
日久生厌 2020-12-20 06:07

I have the following code:

protected override void OnCreate (Bundle bundle)
{
    progress = ProgressDialog.Show(this, \"\", \"Loading...\");
    progress.Se         


        
3条回答
  •  無奈伤痛
    2020-12-20 07:02

    Put android:descendantFocusability="blocksDescendants" in your linear layout of LawsAndRegsListItem, because Android doesn't allow any items to be focusable in listview. Instead of setting every control in your listview to android:focusable="false", the easiest way doing it is setting its root ViewGroup to android:descendantFocusability="blocksDescendants", so it will block every control of it getting focused.

    
    
        ...
    
    

    Also, don't set the LinearLayout's Clickable to true. If so, it will gain focused even though its child won't get focused and thus the listview will block any clicking event.

    References:

    ListView Tips & Tricks #4: Add several clickable areas

    Android Documentation on descendantFocusability

提交回复
热议问题