android - How to add the back arrow in the action bar? -
i wondering how add arrow in action bar. have action bar can add icons @ right hand side , possible center label?
first, you'd have define parent activity
1 you'd display button in. via manifest.
do in androidmanifest.xml
somewhere within application
tag:
<activity android:name="com.example.myfirstapp.displaymessageactivity" android:label="@string/title_activity_display_message" android:parentactivityname="com.example.myfirstapp.mainactivity" > <!-- parent activity meta-data support 4.0 , lower --> <meta-data android:name="android.support.parent_activity" android:value="com.example.myfirstapp.mainactivity" /> </activity>
that done, you'd need call on target activity
, right within oncreate()
method:
getactionbar().setdisplayhomeasupenabled(true);
..or, if happen use appcompat
library in project:
getsupportactionbar().setdisplayhomeasupenabled(true);
you can refer official docs navigation here further details.
Comments
Post a Comment