我有自定义ArrayAdapter的ListView。布局代码的一部分:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center" >
<AutoCompleteTextView
android:id="@+id/aCTVres"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:gravity="center"
android:inputType="textMultiLine"
android:maxHeight="50dp"
android:maxLines="1"
android:textSize="14sp" >
<requestFocus />
</AutoCompleteTextView>
<AutoCompleteTextView
android:id="@+id/aCTVDef"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="3"
android:ems="10"
android:gravity="center"
android:maxHeight="50dp"
android:maxLines="1"
android:textSize="12sp" />
</LinearLayout>
在getView()中,我将setText()调用到所有AutoCompleteTextView。我需要将焦点返回到第一个AutoCompleteTextView。我怎么能这样做?
答案 0 :(得分:1)
对于 xml :android:completionThreshold="1"
,AutoCompleteTextView
只有threshold
"When threshold is less than or equals 0, a threshold of 1 is applied.".
<AutoCompleteTextView
android:id="@+id/aCTVres"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:gravity="center"
android:inputType="textMultiLine"
android:maxHeight="50dp"
android:maxLines="1"
android:textSize="14sp"
android:completionThreshold="1" >
<requestFocus />
</AutoCompleteTextView>
<强>的java 强>
autotexttiew.setThreshold(2);