So I have an autocomplete view which shows a drop down when I type... But I want the dropdown to be shown when the avtivity starts. So I found this answer which says that using showDropDown()
should work. And it does work in my case when called on any TouchListener or any other user triggered event. But it doesn't work if I directly just use it in onCreate()... The following code in my onCreate() works
final AutoCompleteTextView actv = (AutoCompleteTextView)findViewById(R.id.autoCompleteUserName);
String[] users = getResources().getStringArray(R.array.users);
ArrayAdapter<?> adapter = new ArrayAdapter<Object>(this,R.layout.compose_ac_list_item,users);
actv.setAdapter(adapter);
actv.setOnTouchListener(new View.OnTouchListener(){
@Override
public boolean onTouch(View v, MotionEvent event) {
// WORKS IF USED ON TOUCH
actv.showDropDown();
return false;
}
});
And the following doesn't work
final AutoCompleteTextView actv = (AutoCompleteTextView)findViewById(R.id.autoCompleteUserName);
String[] users = getResources().getStringArray(R.array.users);
ArrayAdapter<?> adapter = new ArrayAdapter<Object>(this,R.layout.compose_ac_list_item,users);
actv.setAdapter(adapter);
actv.showDropDown();