kAnNaN
kAnNaN

Reputation: 3679

android: Get selected item from MultiAutoComplete Textview and maupulate and update the EditView?

1.I have created a MultiAutoCompleteTextview.(I have used SimpleAdapter to display the list)

2.I have tried searching for a string.

3.if i click on an item in the list it displayed the content of it in the EditText.

my question is that is there a possible way to save that text in a string and manipulate that string and display the updated string in the EditText of the MultiAutoCompleteTextVew. 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.

thanks :)

Upvotes: 2

Views: 1916

Answers (1)

Sam
Sam

Reputation: 86948

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);
    }
});

Upvotes: 3

Related Questions