Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I change the hierarchy parent of an activity?

At the moment it is main activity but I want to change it to the Categories activity. Is this where the problem lies?

@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);
like image 555
user2229066 Avatar asked Apr 03 '13 09:04

user2229066


1 Answers

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

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

Substitute PARENT_ACTIVITY_PATH with the name of your parent activity adding also your package name (e.g. com.example.Categories).

like image 174
Mangusto Avatar answered Sep 21 '22 18:09

Mangusto