How to change the parent element of an activity hierarchy?

This is currently the main action, but I want to change it to Category activity. Where is the problem?

@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: // This ID represents the Home or Up button. In the case of this // activity, the Up button is shown. Use NavUtils to allow users // to navigate up one level in the application structure. For // more details, see the Navigation pattern on Android Design: // // http://developer.android.com/design/patterns/navigation.html#up-vs-back // NavUtils.navigateUpFromSameTask(this); return true; } return super.onOptionsItemSelected(item); 
+7
source share
2 answers

Go to AndroidManifest.xml , find your sports activity and add this code

 <activity android:name="Sport" > <meta-data android:name="android.support.PARENT_ACTIVITY" android:value="PARENT_ACTIVITY_PATH" /> </activity> 

Replace PARENT_ACTIVITY_PATH name of your parent action, adding your package name as well (e.g. com.example.Categories).

+14
source

Disconnect @ Mangosto. After adding the parent activity path to your AndroidManifest, add this line to the onCreate method of your sport activity getSupportActionBar().setDisplayHomeAsUpEnabled(true);

0
source

All Articles