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