当前位置:编程学习 > wap >>

求助,Activities can't be added until the containing group has been created

在一个Activity里面放一个抽屉,抽屉里面放个Tab,弄了好久没有成功
	    TabHost  tabHost = (TabHost)findViewById(R.id.tabhost); 
    tabHost.setup( new ActivityGroup().getLocalActivityManager ()); 

    if (tabHost==null)Log.i("JSY", "NULL");
    else Log.i("JSY", "NOTNULL");
   // tabHost= getTabHost();  // The activity TabHost 
  
    TabHost.TabSpec spec;  // Resusable TabSpec for each tab 
        Intent intent;  // Reusable Intent for each tab 
     
        // Create an Intent to launch an Activity for the tab (to be reused) 
        intent = new Intent().setClass(this, MyChanceList.class); 
     
        // Initialize a TabSpec for each tab and add it to the TabHost 
        spec = tabHost.newTabSpec(res.getString(R.string.str_forecast)).setIndicator(res.getString(R.string.str_forecast), 
                          res.getDrawable(R.drawable.icon)) 
                      .setContent(intent); 
        tabHost.addTab(spec); 
     
        // Do the same for the other tabs 
        intent = new Intent().setClass(this, OtherChanceList.class); 
        spec = tabHost.newTabSpec(res.getString(R.string.str_history)).setIndicator(res.getString(R.string.str_history), 
                          res.getDrawable(R.drawable.icon)) 
                      .setContent(intent); 
        tabHost.addTab(spec); 
        tabHost.setCurrentTab(0); 


错误信息如下
--------------------编程问答-------------------- 应该是前两句的问题 --------------------编程问答-------------------- http://stackoverflow.com/questions/3163884/andorid-tabhost-without-tabactivity 解决了 --------------------编程问答-------------------- 不的不说stackoverflow的效率太高了 
我也深受其益  --------------------编程问答-------------------- 高手
补充:移动开发 ,  Android
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,