TabHost失去了对意图的看法

时间:2015-09-12 13:25:52

标签: android android-intent view android-tabhost

我在TabHost(MainActivityTabs)中有两个选项用于两个活动。我的问题是当我尝试使用意图从第一个活动打开第二个活动时,TabHost会丢失其视图,这意味着无法看到底部有两个标签,第二个活动在全屏幕上。

〜主要活动〜

public class MainActivityTabs extends TabActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main_tabs);

    Resources ressources = getResources();

    TabHost tabHost = getTabHost();
    TabHost.TabSpec spec;
    Intent intent;


    intent = new Intent().setClass(this, First.class);
    spec = tabHost
            .newTabSpec("First")
            .setIndicator("",
                    ressources.getDrawable(R.drawable.search))
            .setContent(intent);
    tabHost.addTab(spec);


    intent = new Intent().setClass(this, Second.class);
    spec = tabHost
            .newTabSpec("Second")
            .setIndicator("", ressources.getDrawable(R.drawable.favorites))
            .setContent(intent);
    tabHost.addTab(spec);

    tabHost.setCurrentTab(2);
}

}

~first class ~


    public class First extends Activity{
      @Override
       protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
    setContentView(R.layout.first);
   Intent intent = new Intent().setClass(this, Second.class);

    int i =1;
    intent.putExtra("somthing", i);
    startActivity(intent);
     }


 }

〜第二课〜

      public class First extends Activity{
    @Override
      protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.sec);

     }


  }

0 个答案:

没有答案