- Title Category
1.1 General title
1.1.1 Title Content Management
1.1.2 Help and Return buttons
1.2 title not logged in
1.3 The title in the landing
1.4 title after landing completed
PackageCom.tsh.lottery.view.manager;ImportCOM.TSH.LOTTERY.R;Importandroid.app.Activity;ImportAndroid.view.View;Importandroid.widget.RelativeLayout;/*** Title Management *@authorTaoshihan **/ Public classTitlemanager {PrivateRelativelayout Generaltitle,unlogintitle,logintitle; Private StaticTitlemanager instance=NewTitlemanager (); PrivateTitlemanager () {} Public StaticTitlemanager getinstance () {returninstance; } /*** Initialize title *@paramActivity*/ Public voidinit (activity activity) {Generaltitle=(relativelayout) Activity.findviewbyid (r.id.title_general); Logintitle=(relativelayout) Activity.findviewbyid (R.id.title_login); Unlogintitle=(relativelayout) Activity.findviewbyid (R.id.title_unlogin); } /*** Hide All headings*/ Public voidHidetitle () {generaltitle.setvisibility (view.gone); Unlogintitle.setvisibility (View.gone); Logintitle.setvisibility (View.gone); } /*** Show generic headings*/ Public voidShowgeneraltitle () {hidetitle (); Generaltitle.setvisibility (view.visible); } /*** Show titles that are not logged in*/ Public voidShowunlogintitle () {hidetitle (); Unlogintitle.setvisibility (view.visible); } /*** Show the title that has been landed*/ Public voidShowlogintitle () {hidetitle (); Logintitle.setvisibility (view.visible); }}
- Using ActionBar
2.1 Manifest Text configuration
2.2 New menu resource file
2.3 Activity in the settings
Manifest file:
Set the theme is Theme.holo below it can be
<application android:theme= "@android: Style/theme.holo.light" >
Menu file:
The showasaction property inside the item must be filled in, for example: always meant to be displayed,never not displayed
The Actionviewclass property lets you set the View control, for example:android.widget.SearchView is a display search
Fix overflow button not visible problem:
When there is a physical menu Key, this problem occurs, only press the physical menu Key, the hidden button comes out from below
Modifying the shaspermanentmenukey static variable of the Viewconfiguration class using Reflection
/*** Add Menu*/@Override Public BooleanOncreateoptionsmenu (Menu menu) {menuinflater inflater=Getmenuinflater (); Inflater.inflate (R.menu.menu, menu); return Super. Oncreateoptionsmenu (menu); } /*** Solve the problem of Actionbar*/ Public voidsetoverflowmenuques () {viewconfiguration viewconfiguration=viewconfiguration.get ( This); Try{Field field=viewconfiguration.class. Getdeclaredfield ("Shaspermanentmenukey"); Field.setaccessible (true); Field.setboolean (Viewconfiguration,false); } Catch(Exception e) {e.printstacktrace (); } }
<?XML version= "1.0" encoding= "Utf-8"?><Menuxmlns:android= "Http://schemas.android.com/apk/res/android" > <ItemAndroid:id= "@+id/menu_search"Android:actionviewclass= "Android.widget.SearchView"android:showasaction= "Always"Android:title= "Search"/> <Itemandroid:showasaction= "Always"Android:id= "@+id/menu_user"Android:title= "User"/> <Itemandroid:showasaction= "Never"Android:id= "@+id/menu_cart"Android:title= "Shopping"/> <Itemandroid:showasaction= "Always"Android:id= "@+id/menu_edit"Android:title= "Edit"/> <Itemandroid:showasaction= "Never"Android:id= "@+id/menu_setting"Android:title= "Settings"/></Menu>
[Android] title section administration