1

我在我的 TabView 中实现了一个 ActivityGroup。

我可以从选项卡中的活动成功地将视图添加到 ActivityGroup。

如何从堆栈中弹出这个新视图以返回原始视图?

在 ActivityGroup 中,我使用 Finsih() 处理 BackButton,但整个应用程序消失并显示主屏幕。请注意,该应用程序没有被杀死,它仍在运行。

(用 .NET 编写)

public override void OnBackPressed ()
    {
        int length = mIdList.Count;
        if (length > 1)
        {
            Activity current = LocalActivityManager.GetActivity (mIdList [length - 1]);
            current.Finish();
        }           
        base.OnBackPressed ();
    }

(我来自iOS背景)

4

1 回答 1

0

First, I agree with aneal that you should try Fragments rather than activity groups. If you do, the following text from the Android on-line training class appears to address the issue:

Keep in mind that when you perform fragment transactions, such as replace or remove one, it's often appropriate to allow the user to navigate backward and "undo" the change. To allow the user to navigate backward through the fragment transactions, you must call addToBackStack() before you commit the FragmentTransaction.

When you add the view, call addToBackStack() before committing your "add fragment" transaction.

于 2012-10-07T14:19:28.680 回答