[Android] Title section management

Source: Internet
Author: User

    1. 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); }}

    1. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.