5

我正在制作包含三个选项卡的 android 应用程序。在第三个选项卡上有登录屏幕。

当我点击登录按钮时......我想用包含列表视图和注销按钮的活动替换活动......

以前我使用活动组来替换活动..但是活动组现在已弃用..

现在如何替换第三个选项卡下的活动?

我正在使用这些代码

Intent intent = new Intent(MyApp.this, LoginPage.class);

                    replaceContentVieww("activity4", intent);



  public void replaceContentVieww(String id, Intent newIntent) {
                    // TODO Auto-generated method stub


View view = getLocalActivityManager().startActivity(id,newIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)).getDecorView(); 
                            setContentView(view);


                    }

有一个链接,我知道这个类已被弃用。

4

2 回答 2

4

您应该在兼容性包中使用 Fragment 和 FragmentManager

http://developer.android.com/sdk/compatibility-library.html

使用 ADT 下载它,然后转到这里的示例 extras/android/compatibility/v4/samples/

于 2011-09-28T07:34:36.613 回答
0

现在如何替换第三个选项卡下的活动?

您可以将选项卡内容定义为FrameLayout(通过setContent()采用小部件 ID 的 )或动态创建的View(通过setContent()采用TabContentFactory)的现有子项。

于 2011-09-28T11:38:52.917 回答