I wanted to implement ActionBar (Android 4.0) in a test application to see how it works, etc.
My question is: almost all applications for 4.0 have in the right corner of the ActionBar a "menuButton" with an icon that shows 3 vertical dots. (See: http://cdn.gottabemobile.com/wp-content/uploads/2011/12/ICS-Screen05.jpg )
How can I implement this in my application?
I tried to implement this "menuButton" using ah Spinneradapter .. but this is always displayed after the application name in the ActionBar.
Btw. Another question: I have an update button in my application .. how can I spin the "Refresh-Icon" every time I click?
Here is my code ...
Thanks for the help, and please excuse my programming skills ... I'm new! :)
public class IVOAppActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ActionBar actionBar = getActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST); SpinnerAdapter mSpinnerAdapter = ArrayAdapter.createFromResource(this, R.array.action_list, android.R.layout.simple_spinner_dropdown_item); actionBar.setListNavigationCallbacks(mSpinnerAdapter, null); setContentView(R.layout.main); } public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.menubar, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) {
XML ActionBar
<?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android" > <item android:id="@+id/menu_refresh" android:icon="@drawable/ic_popup_sync_1" android:showAsAction="always"/> <item android:id="@+id/menu_settings" android:icon="@drawable/ic_menu_preferences" android:showAsAction="always"/></menu>
source share