列表视图项目单击无法工作 [英] Listview itemclick not work

查看:98
本文介绍了列表视图项目单击无法工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  1. 我在我的ListView显示的ImageButton一个ListView。

  2. 我设置focusalble假和focusableInTouchMode假来的ImageButton。

  3. 我设置ListView.OnItemClickListner。当我运行我的项目,这是展示我的ListView。

  4. 不过,当我点击列表视图它不工作。

  5. 然后,我删除ImageButton的布局,然后再次运行我的项目,当我点击的ListView它的工作

  6. 有什么错?

解决方案

 机器人:可调焦=假
机器人:focusableInTouchMode =假
 

不适合的ImageButton工作

在你的布局XML,这个属性添加到根布局

 安卓descendantFocusability =blocksDescendants
 

它完美的一个ListView具有的ImageButton。

  1. I have a ListView in my ListView show ImageButton.

  2. I set focusalble "false" and focusableInTouchMode "false" to ImageButton.

  3. I set ListView.OnItemClickListner. When I run my project It's show my ListView.

  4. But When I click on Listview It's not working.

  5. Then I remove ImageButton in layout and run my project again when i click ListView It' work

  6. What wrong ?

解决方案

android:focusable="false"
android:focusableInTouchMode="false"

doesn't work for ImageButton.

In your layout xml, add this property to root layout

android:descendantFocusability="blocksDescendants" 

It works perfectly for a listview that has ImageButton.

这篇关于列表视图项目单击无法工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆