a textview in a listview' s row cannot click after setting descendantFocusability=“blocksDescendants”

前端 未结 1 712
滥情空心
滥情空心 2021-01-23 16:24

I write a customized item layout for a listview. The layout has many widgets and some will have its own clicklistener.

When I click the row, sometimes the listview\' s o

相关标签:
1条回答
  • 2021-01-23 17:13

    After spenting some time trying, I solved both.

    1. the first. if your customized listview' s layout has a textview which has been set autolink or Linkify in the code, the click event in the textview won' t affect the list' s row. You have to extends your own TextView and override onTouchEvent method. please see it here

    2. the second. just set in the customized listview' s root node: android:descendantFocusability="blocksDescendants", and then, in your widget which will have its own onClickListener, set android:clickable="true", it works for me.

    hope it useful for those you encounter the same:-)

    0 讨论(0)
提交回复
热议问题