Action Bar Action Bar Contains Logo Application Name Options Menu SW in Android 3.0 and above was HW in Older Versions
Action Bar & Options Menu Older Versions vs Newer Versions
Options Menu public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu adding items to the action bar getMenuInflater().inflate(R.menu.my, menu); return true; }
Menu Items If (menu items do not displayed in the action bar) → {they are shown in the overflow menu} Otherwise → {they are called action items}
ShowAsAction Values
Menu Item Icon (1) 1- System Drawable Resources (android.R.drawable) contains many suitable menu icons should not be used directly
Menu Item Icon (2) 2- Other Resources resource.html resource.html
onOptionsItemSelected Toast.makeText( getApplicationContext(), item.getTitle(), Toast.LENGTH_SHORT).show();
Action Bar New Features 1- Drop Down Navigation * R.layout.simple_spinner_item (Spinner) * R.layout.simple_spinner_dropdown_item (AutoCompleteTextView) * Creating Custom Layout 2- Tabs for Navigation
Drop Down Navigation Code
Tabs for Navigation Code
Old Android Versions Tips Use menu options only Create an initial branching activity if (android.os.Build.VERSION.SDK_INT>= android.os.Build.VERSION_CODES.HONEYCOMB) {} Create a layout for versions lower than Honeycomb Use a third-party product called ActionBarSherlock