Android AutocompleteView OnClickListener
- by Chirag_RB
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);
}
});