Im My application I want the below type of Spinner Dropdown view . For this type of spinner view. I wrote this code.
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this,
R.array.spinner, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner_obj.setAdapter(adapter);
I got this from http://developer.android.com/guide/topics/ui/controls/spinner.html But what I got is,
Please provide me the best way to do this....
You can also affect drop down view location and size by subclassing Spinner and overriding its getWindowVisibleDisplayFrame(Rect outRect) which is used by android. widget. PopupWindow for calculations. Just set outRect to limit the area where drop down view can be displayed.
Kind of reviving an old post here but the accepted answer is far from ideal. The correct way to do this is to set the Spinner to dropdown mode in your layout xml:
<Spinner
android:id="@+id/my_spinner"
...
android:spinnerMode="dropdown"/>
The available options are "dialog" and "dropdown".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With