How to make spinner like actionbar in native andro

2019-06-04 03:00发布

问题:

After using Actionbar i thought that what if same widget could be available for native android platform. I dont know if we can grab the styles and apply it to native widgets from actionbar apis(compatibility library v4) or not.

What i am asking is spinner widget like below which is mostly used in actionbar.

Check for dropdown widget.

Is it possible to use the same in native like in Listview ?

Many thanks.

回答1:

adapter = new ArrayAdapter<CharSequence>(this,android.R.layout.simple_spinner_item, spinnerArrayList);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);

Set DropDownViewResource will work

What's more: In your layout file Add the follow code for your Spinner

style="@android:style/Widget.DeviceDefault.Light.Spinner"