user2256209
user2256209

Reputation: 41

How to set the spinner mode dynamically?

I have created a Spinner dynamically, which is easy with new Spinner(context).
But now I need to set the spinnerMode dynamically, and I find no method to do so.

What should I do?

Upvotes: 4

Views: 5054

Answers (2)

ali safaei
ali safaei

Reputation: 131

in android >= 3.0 (API 11) you can use this :

    Spinner spinner = new Spinner(this,null,android.R.style.Widget_Spinner,Spinner.MODE_DROPDOWN);

Upvotes: 4

ridoy
ridoy

Reputation: 6332

OK you can try with..

Spinner spinner = new Spinner(this);
ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, yourArrayAdapter);
spinner.setAdapter(spinnerArrayAdapter);

Or,

Spinner spinner = new Spinner(this);
ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item, yourArrayAdapter);
spinner.setAdapter(spinnerArrayAdapter);

Also you can see..

Upvotes: -1

Related Questions