0

我在我的应用程序中使用了带有活动组的标签栏。我有四个标签,例如 home、stock、citn、article。在我的应用程序中,首先显示主页用户在 webview 中单击它将转到 homepage1 活动。从主页 1 活动用户单击股票选项卡,它将转到股票活动。从股票活动用户单击主页选项卡,它将转到 homepage1 活动。我想显示家庭活动,任何机构都可以告诉我该怎么做吗?

我的问题是使用活动组在选项卡之间切换,它将显示最后一个活动。我想显示第一个活动?

好的,我会附上我的代码

spec = tabHost.newTabSpec("FirstGroup").setIndicator("FirstGroup",   
                getWallpaper()).setContent( new Intent(this,FirstGroup.class));
        tabHost.addTab(spec);   

查看视图 = getLocalActivityManager().startActivity("CitiesActivity", new Intent(this,CitiesActivity.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET )).getDecorView();

          // Replace the view of this ActivityGroup   
      replaceView(view);   

   }   

public void replaceView(View v) {   
            // Adds the old one to history   
    history.add(v);   
            // Changes this Groups View to the new View.   
    setContentView(v);

运行此示例 http://united-coders.com/nico-heid/use-android-activitygroup-within-tabhost-to-show-different-activity

在活动和标签之间切换

我已经在 pastebin 中发布了,我的链接是 http://pastebin.com/1zG0HJgv

4

1 回答 1

1

嗨,您尝试过 tabchanged 事件吗,如下所示

tabHost.addTab(tabHost.newTabSpec("tab1").setContent(
                R.id.content_movies).setIndicator("",
                getResources().getDrawable(R.drawable.icon)));
        tabHost.addTab(tabHost.newTabSpec("tab2").setContent(
                new Intent(this, Sample.class)).setIndicator("",
                getResources().getDrawable(R.drawable.menu_icon)));
    tabHost.setOnTabChangedListener(new TabHost.OnTabChangeListener() {

       @Override
       public void onTabChanged(String arg0) {


         if(arg0.equals("tab1"))
        {

       /*write the code here to show the view 
     Currentclass, the class where you have used ontabchanged function and 
     Newclass is the class where you want to navigate*/
           Intent obj_intent = new Intent(CureentClass.this,Newclass.class);
    startActivity(obj_intent);

        }

        else if (arg0.equals("tab2")) {

                 // write the code here to show the view 
       }
       //similarly for other tabs
      });
于 2010-12-06T09:20:50.023 回答