Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add dropdown menu to ActionBar in Android project?

Tags:

android

I had been developing Android applications, but I don't know much about 4+ versions of Android well. Therefore, please help me - I have made Android application with tabs for navigation:

final ActionBar actionBar = getActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

But I also need to add dropdown menu to ActionBar for other goals. Can I do it? Please, if it's possible, give me an example. Thank you in advance.

like image 523
malcoauri Avatar asked Jan 31 '26 08:01

malcoauri


1 Answers

You can use something called an android spinner. It looks like this:

enter image description here

You can customize it in many ways to suit your apps design too.

Here's a great tutorial by Google on how to use these:

http://developer.android.com/guide/topics/ui/controls/spinner.html

If you want to add this to an action bar, you can do it via a spinner adapter as detailed here: http://developer.android.com/guide/topics/ui/actionbar.html#Dropdown

If you want to add icons to do certain actions, then you can see this: http://developer.android.com/guide/topics/ui/actionbar.html#ActionItems

If you want to do certain actions in the bar itself (like search in the google search app) then see this: http://developer.android.com/guide/topics/ui/actionbar.html#ActionView

If you want to add navigation tabs, then see this: http://developer.android.com/guide/topics/ui/actionbar.html#Tabs

like image 182
Anup Cowkur Avatar answered Feb 01 '26 23:02

Anup Cowkur



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!