---
title: "Show DropDown onCreate not working in android"  
description: "Show DropDown onCreate not working in android"  
author: "Anonymous User"  
published: 2014-11-07  
updated: 2014-11-07  
canonical: https://www.mindstick.com/forum/2540/show-dropdown-oncreate-not-working-in-android  
category: "android"  
tags: ["autocomplete"]  
reading_time: 2 minutes  

---

# Show DropDown onCreate not working in android

So I have an [autocomplete](https://www.mindstick.com/forum/156169/what-is-google-suggest-or-autocomplete) [view](https://yourviews.mindstick.com/view/84701/layoffs-in-google-india-2023-view) which [shows](https://yourviews.mindstick.com/view/81380/new-york-violent-shooting-shows-people-are-not-safe-in-night-life) a [drop down](https://www.mindstick.com/forum/263/drop-down-list-problem) when I type... But I want the [dropdown](https://www.mindstick.com/articles/263/ajax-toolkit-dropdownextender-in-asp-dot-net) to be shown when the avtivity starts. So I found this [answer](http://stackoverflow.com/questions/2126717/android-autocompletetextview-show-suggestions-when-no-text-entered) which says that using showDropDown() should work. And it does work in my case when called on any TouchListener or any other [user](https://www.mindstick.com/articles/13001/multi-statement-table-valued-user-defined-function-in-sql-server) triggered [event](https://www.mindstick.com/articles/167719/marquee-hire-benefits-of-event-lighting-hire-london). But it doesn't work if I directly just use it in onCreate()... The following [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii) 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();
```

## Replies

### Reply by Anonymous User

Because when you call setAdapter it takes some time to inflate all the list items. During this time if you call **showDropDown()** the listview hasn't inflated yet so it won't be able to show the [drop](https://www.mindstick.com/forum/159392/how-to-fetch-the-value-of-the-selected-options-in-drop-down-in-php) down. You could give some delay before calling the showDropDown(). But I'm not sure if this is the efficient solution as we won't be knowing for sure that how much time it is going to take to inflate the list items.

```
    actv.setAdapter(adapter);
    new Handler().postDelayed(new Runnable() {

        @Override
        public void run() {
            actv.showDropDown();
        }
    }, 500);
```


---

Original Source: https://www.mindstick.com/forum/2540/show-dropdown-oncreate-not-working-in-android

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
