Development steps:?
- Create a actionbar_menu_register.xml menu resource file in the menu folder under Res?
- To add a label to a resource file set one or more Actionbar feature options
1 //actionbar_menu_register.xml2 3 <?XML version= "1.0" encoding= "Utf-8"?>4 <MenuXmlns:app= "Http://schemas.android.com/apk/res-auto"5 xmlns:android= "Http://schemas.android.com/apk/res/android">6 <Item7 Android:id= "@+id/ab_return"8 android:orderincategory= "1"9 app:showasaction= "Ifroom|withtext"Ten Android:title= "Back"/> One </Menu>
- In the Java org.socrates.mydiay.activity under Registeractivity.java, override the parent class method to complete the Actionbar setting
1 //Register_activity.java2 3 Public classRegister_activityextendsappcompatactivity {4 ......5 Public BooleanOncreateoptionsmenu (Menu menu) {6Menuinflater Inflater=getmenuinflater ();//Step 1: Dynamically introduce the layout file for the menu7Inflater.inflate (R.menu.actionbar_menu_register,menu);//Step 2: Bind the layout file using the Inflater method in Inflater8 return true;9 }Ten ...... One}
Run:
Summary: Ctrl+o call up method list, direct input Oncreateo find Oncreateoptionsmenu method
Application of the Actionbar component for the optimization of the Registration Interface (i) Actionbar component layout implementation