Android AutocompleteView OnClickListener
Posted
by
Chirag_RB
on Stack Overflow
See other posts from Stack Overflow
or by Chirag_RB
Published on 2012-02-29T12:54:26Z
Indexed on
2012/07/08
21:16 UTC
Read the original article
Hit count: 152
android
|android-layout
I have 2 Auto Complete Views which i have to pre-populate with some text .However as soon as user clicks on the views , the text should disappear and allow user to enter text . I have written two separate on click listeners to do so . The On click listener for the first one is working fine . However i have to double click for the On click listener of the second one to work. Please find the chunk of code below and come up with some solution .
final AutoCompleteTextView source = (AutoCompleteTextView) findViewById(R.id.source); ArrayAdapter source_adapter = new ArrayAdapter(this, R.layout.list_item, Model.City); source.setAdapter(source_adapter);
source.setOnClickListener(new OnClickListener(){
public void onClick(View v) {
source.setText("");
source.setTextSize(14);
}
});
final AutoCompleteTextView destination = (AutoCompleteTextView) findViewById(R.id.destination); ArrayAdapter destination_adapter = new ArrayAdapter(this, R.layout.list_item, Model.City); destination.setAdapter(destination_adapter);
destination.setOnClickListener(new OnClickListener(){
public void onClick(View v) {
destination.setText("");
destination.setTextSize(14);
}
});
© Stack Overflow or respective owner