Activity return button

Source: Internet
Author: User

1  PackageCom.maomao.beautymovie;2 3 ImportAndroid.app.ActionBar;4 Importandroid.app.Activity;5 ImportAndroid.os.Bundle;6 Importandroid.support.v4.app.FragmentActivity;7 Importandroid.view.KeyEvent;8 ImportAndroid.view.MenuItem;9 Ten  One /** A  *  -  * @authorNingxuefeng -  * the  */ -  Public classBaseactivityextendsActivity { -  -     protectedActionBar Mactionbar; +  -     protected voidonCreate (Bundle savedinstancestate) { +         Super. OnCreate (savedinstancestate); A Initactionbar (); at     } -  -     Private voidInitactionbar () { -Mactionbar =Getactionbar (); -Mactionbar.setdisplayhomeasupenabled (true);//Add a return icon "" to the left of the upper left corner icon. Correspondence Actionbar.display_home_as_up -Mactionbar.setdisplayshowhomeenabled (true);//make the upper left corner icon clickable and the corresponding ID for Android. R.id.home, corresponding Actionbar.display_show_home false the icon cannot be clicked inMactionbar.sethomebuttonenabled (true);//false You cannot click -     } to  +      Public voidSettitle (intresId) { - Mactionbar.settitle (resId); the     } *  $      Public voidsettitle (charsequence text) {Panax Notoginseng mactionbar.settitle (text); -     } the  + @Override A      Public Booleanonoptionsitemselected (MenuItem item) { the         Switch(Item.getitemid ()) { +                CaseAndroid. R.id.home: - onbackpressed (); $                   return true; $             default: -                 return Super. onoptionsitemselected (item); -         } the     } - Wuyi  the}

Activity return button

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.