user2909337
user2909337

Reputation: 25

Text in autocompletetextview to be highlighted or deleted when the user clicks on the AutoCompleteTextView

When a user click on an ACTV and finds what he is searching for, the only reason for him to select the ACTV again is to search for something else. I am looking for a way where when user has made a search in the ACTV and the search text is in the ACTV field (suggestions menu is closed) when the user clicks on the ACTV to write again, the current text to be highlighted or deleted on the click that opens the keyboard for the user to start typing their new search.

Upvotes: 1

Views: 1036

Answers (2)

chandramohan
chandramohan

Reputation: 576

For highlighting:

android:selectAllOnFocus="true" (xml attribute)

or

autoCompleteTextView.setSelectAllOnFocus(true); (programmatically)

Upvotes: 2

bobby.dhillon
bobby.dhillon

Reputation: 319

Try this:

AutoCompleteTextView search = (AutoCompleteTextView) findViewById(R.id.search);

search.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    // Do what ever you want
                              (AutoCompleteTextView) findViewById(R.id.search).setText(""); 
                }
            });

Upvotes: 1

Related Questions