1.我创建了一个MultiAutoCompleteTextview。(我使用SimpleAdapter来显示列表)
2.我尝试过搜索字符串。
3.如果我单击列表中的某个项目,它会在 EditText 中显示其内容。
我的问题是,是否有一种可能的方法将该文本保存在字符串中并操作该字符串并在 MultiAutoCompleteTextVew 的 EditText 中显示更新后的字符串。例如,如果列表显示姓名列表,并且如果我选择了一个姓名“Mr.X”(默认情况下它将在 EditText 中显示文本“Mr.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/