Button click and ListView click

夙愿已清 提交于 2019-12-12 02:12:22

问题


I have a ListView. on click of a list item I start a Activity. Now I have added a Button on that ListView and onclick of a button I want to start a another activity. After adding a Button, I can click on the button and start a Activity but now I can not click a list item. What happened to listview's item click ??


回答1:


Read this excellent blog post: Focus problems with list rows and ImageButtons

Essentially you should add the following to your root layout element in the row-item xml.

android:descendantFocusability="blocksDescendants"




回答2:


that is the concept. If u want to implement both clicks then write button click normally and for list item click did not use the listitem click.

Instead that you write onclick listener for converted view that you returned in getview()

Then both clicks will work



来源:https://stackoverflow.com/questions/7533027/button-click-and-listview-click

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