setOnItemClickListener()不工作自定义的ListView @安卓 [英] setOnItemClickListener() not working on custom ListView @ Android
问题描述
我通过扩展的LinearLayout
的每一行实现了自定义的ListView
。每一行都有一个小的缩略图,文本和复选框
。该列表视图
的正确部署,我可以滚动一扔通过它没有任何问题。
I have Implemented a custom ListView
by extending LinearLayout
for every row. Every row has a small thumbnail, a text and a check box
. The list view
is deployed properly and I can scroll and fling through it without any problems.
但的ListView
似乎并没有在所有响应 setOnItemClickListener()
,所以我不得不通过设置点击监听器的 getView()
的每一行中的文本这显然是创建问题,当我试图重新使用的适配器找到一个解决办法
。有没有人有办法解决吗?
But The ListView
doesn't seem to respond to the setOnItemClickListener()
at all, So I had to find a workaround by setting click listener in the getView()
of the Text inside every row which is obviously creating problem when I am trying to reuse the adapter
. Does anyone have a solution?
推荐答案
试试这个
对于ListView控件,
Try this
For ListView,
final ListView list = (ListView) findViewById(R.id.list);
list.setItemsCanFocus(false);
此外,还要确保为复选框内的列表项设置可聚焦假
Also, make sure that for CheckBox inside list item set focusable false
android:focusable="false"
android:focusableInTouchMode="false"
这篇关于setOnItemClickListener()不工作自定义的ListView @安卓的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!