How to do get a listdropdown on clicking sherlock action item.It should be similar to creating spinner. But I have a problem with that approach as I dont want the selected item to be shown on the actionbar.it should be similatr to action overflow.Can any on help me on this.Thanks in advance.
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
You can create such behavior using
Spinner
(orIcsSpinner
forActionBarSherlock
) in action layout of a menu item. Though you have to use a little trick - hide the currently selected item.Create menu xml:
Where
res/layout-v14/my_dropdown_action_layout.xml
will contain (this version is used for native action bar):and
res/layout/my_dropdown_action_layout.xml
will contain (this version is used forActionBarSherlock
):Using
IcsSpinner
is necessary to create a dropdown spinner. If you useres/layout-v14/my_dropdown_action_layout.xml
layout for the default version (inres/layout/
), it would behave differently on Android 2.x (the spinner would be in dialog mode).Now you have to fill the spinner with data properly. Just create an
Activity
where you inflate the menu, this way:Now comes the trick of hiding the currently selected item. Layout
res/layout/spinner_layout.xml
will contain this:This way you see an icon as the menu item and you have the dropdown menu. Note that layout
res/layout/list_item.xml
has to contain aTextView
with idR.id.text
too.Alternatively, you can use similar approach where you can use
ActionProvider
instead of action layout.And another solution would be to create custom widget similar to dropdown
Spinner
.