1

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

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

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

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

谢谢 :)

4

1 回答 1

2

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.

(Honestly, this is the only part of your question that I understood. So I'll base my answer off of this example.)

Simply override a click listener to add the data that you want, like this:

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);
    }
});
于 2012-05-24T22:06:00.250 回答