gpt4 book ai didi

android - AutoCompleteTextView 光标应移动到下一个 AutoCompleteTextView/EditTextBox 选择建议

转载 作者:行者123 更新时间:2023-11-29 17:44:15 27 4
gpt4 key购买 nike

当我单击 AutoCompleteTextView 的建议时,我希望光标移动到下一个可用的 EditBox 或 AutoCompleteTextView。

我在下面附上了我的布局和我的应用图像文件。在此图像中,如果我选择 Chennai Central (MAS),我想在 From TextBox 中填充数据并移动到下一个 TO TextBox。

Image

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="5dp">
<AutoCompleteTextView android:id="@+id/autocompleteFrom"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="From Station"
android:singleLine="true"
android:inputType="textNoSuggestions"
android:layout_marginLeft="5dp"
android:imeOptions="actionNext"
/>

<AutoCompleteTextView android:id="@+id/autocompleteTo"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/autocompleteFrom"
android:hint="To Station"
android:singleLine="true"
android:inputType="textNoSuggestions"
android:layout_marginLeft="5dp"
android:imeOptions="actionDone"
/>

<Button android:text="Find Trains"
android:id="@+id/findTrains"
android:layout_below="@id/autocompleteTo"

android:layout_width="wrap_content"
android:layout_height="wrap_content"/>

</RelativeLayout>

非常感谢任何帮助!

最佳答案

如果我理解了问题,

    AutoCompleteTextView acFrom = (AutoCompleteTextView) findViewById(R.id.autocompleteFrom )
acFrom.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> p, View v, int pos, long id) {
//TODO: set focus on next view
AutoCompleteTextView acTo = (AutoCompleteTextView) findViewById(R.id.autocompleteTo)
acTo.setFocusableInTouchMode(true);
acTo.requestFocus()
}
});

关于android - AutoCompleteTextView 光标应移动到下一个 AutoCompleteTextView/EditTextBox 选择建议,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27567585/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com