gpt4 book ai didi

android:从 MultiAutoComplete Textview 中获取选定的项目并修改和更新 EditView?

转载 作者:行者123 更新时间:2023-11-29 22:06:15 25 4
gpt4 key购买 nike

1.我创建了一个MultiAutoCompleteTextview。(我使用SimpleAdapter来显示列表)

2.我试过搜索一个字符串。

3.如果我点击列表中的一个项目,它会在 EditText 中显示它的内容。

我的问题是,是否有可能将该文本保存在字符串中并操作该字符串并在 MultiAutoCompleteTextVew 的 EditText 中显示更新后的字符串。例如,如果列表显示名称列表并且如果我选择了一个名称说“X 先生”(默认情况下它将在 EditText 中显示文本“X 先生”),但我希望它显示“Mr.X”。 X - 男性,”在 EditText 中。

谢谢:)

最佳答案

For example if the list show the list of name's and if i selected a name say "Mr.X" (by default it will display the text "Mr.X," in the EditText), but i want it to display "Mr.X - Male," in the EditText.

(老实说,这是你问题中我唯一理解的部分。所以我的回答将基于这个例子。)

只需覆盖点击监听器即可添加所需的数据,如下所示:

mAutoComplete.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view, int index, long position) {
// Query your data to determine if the person is male or female and store it in gender;
String text = mAutoComplete.getText().toString();
gender = determineGender(text); // returns a string either "Male" or "Female"
mAutoComplete.setText(text + " - " + gender);
}
});

关于android:从 MultiAutoComplete Textview 中获取选定的项目并修改和更新 EditView?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10745435/

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