处理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或我必须使用另一种类型的视图 .
1 回答
简单地使
ToggleButton
从行不可聚焦(使用android:focusable="false"
或在代码中,在适配器中,btn.setFocusable(false)
) .