P
P
Pavel Dmitriev2014-08-06 11:51:27
Java
Pavel Dmitriev, 2014-08-06 11:51:27

How to bring back button to settings screen?

I made a "back" button on the settings screen and it does not appear.
9c5b002b19084ffd9c95a352a75b0fe5.png
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);
    }

code in manifest
<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

1 answer(s)
I
Ivan Lebedev, 2014-08-06
@klieve

developer.android.com/training/implementing-naviga...

@Override
public void onCreate(Bundle savedInstanceState) {
    ...
    getActionBar().setDisplayHomeAsUpEnabled(true);
}

or
developer.android.com/reference/android/R.attr.htm...
<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 question

Ask a Question

731 491 924 answers to any question