【问题标题】:AutoCompleteTextView Items not Clickable when containing ToggleButton包含 ToggleButton 时 AutoCompleteTextView 项目不可点击
【发布时间】:2013-07-25 11:39:53
【问题描述】:

我在处理 AutoCompleteTextViews 时遇到了一个奇怪的问题。 我的项目有以下布局:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="48dp"
android:orientation="horizontal"
android:padding="8dp" >

<TextView
    android:id="@+id/name"
    android:layout_width="0dp"
    android:layout_weight="1"
    android:layout_height="wrap_content"
    android:layout_gravity="center_vertical"
    android:text="Some place I already visited"
    android:textAppearance="?android:attr/textAppearanceMedium" />

<ToggleButton android:id="@+id/starred"
    android:layout_width="32dp"
    android:layout_height="32dp"
    android:layout_gravity="center"
    android:background="@drawable/starred"
    android:textOn=""
    android:textOff=""/>
</LinearLayout>

现在我的适配器将 ToggleButton 的 Visiblity 设置为某些项目为 Gone 和其他项目为 Visible。它消失的项目按预期工作,您可以单击它们并将文本放入 AutoCompleteTextView 但在 ToggleButton 可见的项目不响应触摸。尽管您可以与 ToggleButton 进行交互。

有没有办法使这个工作与 AutoCompleteTextViews 一起工作,还是我必须使用另一种类型的视图。

【问题讨论】:

  • 简单地使ToggleButton 不可聚焦(使用android:focusable="false 或代码btn.setFocusable(false))。
  • @Luksprog 谢谢你工作得很好,如果你把它作为答案发布,我很乐意接受它

标签: android autocompletetextview


【解决方案1】:

简单地使行中的ToggleButton 不可聚焦(使用android:focusable="false" 或在代码中,在适配器中btn.setFocusable(false))。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-09-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多