Answer the question
In order to leave comments, you need to log in
How to bring back button to settings screen?
I made a "back" button on the settings screen and it does not appear.
Is this button possible on the settings screen?
button code
/** Назад к родительскому активити */
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
// Respond to the action bar's Up/Home button
case android.R.id.home:
Intent upIntent = NavUtils.getParentActivityIntent(this);
if (NavUtils.shouldUpRecreateTask(this, upIntent)) {
// This activity is NOT part of this app's task, so create a new task
// when navigating up, with a synthesized back stack.
TaskStackBuilder.create(this)
// Add all of this activity's parents to the back stack
.addNextIntentWithParentStack(upIntent)
// Navigate up to the closest parent
.startActivities();
} else {
// This activity is part of this app's task, so simply
// navigate up to theMain logical parent activity.
NavUtils.navigateUpTo(this, upIntent);
}
return true;
}
return super.onOptionsItemSelected(item);
}
<activity
android:name=".Setting"
android:label="@string/mysetting"
android:icon="@drawable/ic_setting_off"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Holo">
<!-- Назад к родительскому активити -->
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".Main" />
</activity>
Answer the question
In order to leave comments, you need to log in
developer.android.com/training/implementing-naviga...
@Override
public void onCreate(Bundle savedInstanceState) {
...
getActionBar().setDisplayHomeAsUpEnabled(true);
}
<style name="ActionBarStyle">
...
<item name="android:displayOptions">showTitle|homeAsUp</item>
<item name="displayOptions">showTitle|homeAsUp</item>
</style>
<style name="Theme.UpTheme" parent="Theme.Holo">
...
<item name="android:actionBarStyle">@style/ActionBarStyle</item>
</style>
<activity
....
android:theme="@style/Theme.UpTheme"/>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question