Action Bar Action Bar Contains Logo Application Name Options Menu SW in Android 3.0 and above was HW in Older Versions
Dec 13, 2015
Action Bar
Action Bar Contains Logo Application Name Options Menu
SW in Android 3.0 and above was HW in Older Versions
Options Menu
Code
@Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu adding items to the action bar
getMenuInflater().inflate(R.menu.my, menu); return true;
}
Menu Items
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}
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 http://developer.android.com/guide/topics/resources/menu-reso
urce.html http://androiddrawables.com/
android:icon="@+drawable/menu_icon_name"
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
Old Android Versions Tips
Use menu options only
Create an initial branching activityif (android.os.Build.VERSION.SDK_INT>=
android.os.Build.VERSION_CODES.HONEYCOMB) {}
Create a layout for versions lower than Honeycombhttp://developer.android.com/samples/index.html
Use a third-party product called ActionBarSherlock