标签栏中的活动组问题

时间:2010-12-06 07:31:27

标签: android tabbar activitygroup

我在我的应用程序中使用了带有活动组的tabbar。我有四个标签,如家,股票,城市,文章。在我的应用程序首页显示主页,从主页用户点击webview,它将进入homepage1活动。从主页1活动用户单击库存选项卡,它将转到库存活动。从库存活动用户单击主页选项卡,它将转到主页1活动。我想显示家庭活动可以任何身体告诉怎么办?

我的问题是在使用活动组的标签之间切换它会显示最后一个活动。我想显示第一个活动?

好的我会附上我的代码

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

查看视图=   getLocalActivityManager()。startActivity( “CitiesActivity”   新   意图(此,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

1 个答案:

答案 0 :(得分: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
      });
相关问题