如何更改活动的层次结构父级?

use*_*066 7 java android class-hierarchy

目前它是主要活动,但我想将其更改为Categories活动.这是问题所在吗?

@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);
Run Code Online (Sandbox Code Playgroud)

Man*_*sto 14

转到AndroidManifest.xml,找到您的体育活动并添加此代码

<activity android:name="Sport" >
    <meta-data
       android:name="android.support.PARENT_ACTIVITY"
       android:value="PARENT_ACTIVITY_PATH" />
</activity>
Run Code Online (Sandbox Code Playgroud)

替换PARENT_ACTIVITY_PATH为您父项活动的名称,同时添加您的包名称(例如com.example.Categories).