由于使用了onItemClickListener,存在Button的时候ListView不能监听到点击事件,所以对Button做了如下处理
android:focusable="false"
android:focusableInTouchMode="true"
对Button的父类容器做这样的处理
android:descendantFocusability="blocksDescendants"
之前的ListView监听问题解决了
但是,不知道后续应该怎么做了,我想在button上也添加事件,但是我理解的状态是:目前不能添加事件了,我理解的对不对,请各位大神指教
Do not use the onItemClick event provided by ListView.
Register the onClick event when initializing ItemView.
Then register the onClick event for Button.
ListView
的ItemView
If any focusable View is used, the click event of ItemView will be intercepted by that type of View. To solve this problem, you only need to set the following attributes to RootView in layout-xml to solve the above problem:It would be nice if you still want to give
ItemView
的ChildView
设置OnClickListener
, 那就直接调用View.setOnClickListener(OnClickListener)
.