【问题标题】:Why ListView Item of custom CursorAdapter does not respond with Image Button?为什么自定义 CursorAdapter 的 ListView 项不响应 Image Button?
【发布时间】:2016-06-12 02:48:44
【问题描述】:

我有一个 ListView 和一个基本的自定义光标适配器。当我添加图像按钮时,列表视图项目不响应项目单击或长项目单击

我将如何解决这个问题?我需要设置可点击的东西吗?

【问题讨论】:

  • 你可以显示你的适配器类。

标签: android listview android-cursoradapter


【解决方案1】:

大概

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

不工作。你必须添加-

android:descendantFocusability="blocksDescendants" 

在您的布局中。请参阅link 了解详情。

您也可以使用 Button 或使用原生布局创建自己的按钮。

【讨论】:

    【解决方案2】:

    如果它适用于普通的Button,也许你可以只设置它的背景而不是使用ImageButton

    【讨论】:

      【解决方案3】:

      可能您需要在 ImageButton 中设置以下内容 -

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

      或者,您可以将 android:descendantFocusability="blocksDescendants" 添加到行布局 XML 的根项中。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-10-06
        • 1970-01-01
        相关资源
        最近更新 更多