Android 包含ToggleButton时,AutoCompleteTextView项目不可单击
我在处理AutoCompleteTextView时遇到了一个奇怪的问题。 我的物品有以下布局:Android 包含ToggleButton时,AutoCompleteTextView项目不可单击,android,autocompletetextview,Android,Autocompletetextview,我在处理AutoCompleteTextView时遇到了一个奇怪的问题。 我的物品有以下布局: <?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:
<?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的可见性,使某些项消失,而另一些项可见。它所在的项目按预期工作,您可以单击它们,文本将被放入AutoCompleteTextView中,但当切换按钮可见时,项目不会对触摸做出响应。尽管你可以通过切换按钮进行交互
有没有一种方法可以让AutoCompleteTextView执行此操作,或者我必须使用另一种类型的视图。简单地使行中的
切换按钮不可聚焦(使用android:focusable=“false”
或在代码中,在适配器中,btn.setFocusable(false)
)@Luksprog感谢您的完美工作,如果您将其作为一个答案发布,我将很高兴地接受它的简单操作,使切换按钮不可聚焦(使用android:focusable=“false
或在codebtn.setFocusable(false)
)。@Luksprog感谢您的完美工作,如果你能把它作为一个答案,我会很高兴地接受它