2012-01-10 79 views
0

我想通过活动组活动加载到一个选项卡,但该活动并非负荷达到高潮在一个IllegalStateException错误:无法通过活动组加载标签活动

这里是日志的副本信息:

01-10 11:01:06.201: INFO/WeatherClockWidgetProvider(582): updateTime 
01-10 11:01:06.201: INFO/WeatherClockWidgetProvider(582): setCalendarInstance 
01-10 11:01:06.211: INFO/WeatherClockWidgetProvider(582): onTimeChanged 
01-10 11:01:06.211: INFO/WeatherClockWidgetProvider(582): mHour01HandIndex = 1 
01-10 11:01:06.211: INFO/WeatherClockWidgetProvider(582): mHour01HandIndex = 1 
01-10 11:01:06.211: INFO/WeatherClockWidgetProvider(582): mHour01HandIndex = 0 
01-10 11:01:06.211: INFO/WeatherClockWidgetProvider(582): mHour01HandIndex = 1 
01-10 11:01:06.211: INFO/WeatherClockWidgetProvider(582): updateTime id = 3 
01-10 11:01:06.211: INFO/WeatherClockWidgetProvider(582): updateCurrentTemperature 
01-10 11:01:06.221: INFO/WeatherClockWidgetProvider(582): changeFtoC 
01-10 11:01:06.251: INFO/WeatherClockWidgetProvider(582): updateCurrentLocal 
01-10 11:01:06.281: INFO/WeatherClockWidgetProvider(582): updateTemperatures 
01-10 11:01:06.281: INFO/WeatherClockWidgetProvider(582): setCalendarInstance 
01-10 11:01:06.291: INFO/WeatherClockWidgetProvider(582): highT = 48 
01-10 11:01:06.291: INFO/WeatherClockWidgetProvider(582): lowT = 43 
01-10 11:01:06.291: INFO/WeatherClockWidgetProvider(582): changeFtoC 
01-10 11:01:06.301: INFO/System.out(8418): waiting for debugger to settle... 
01-10 11:01:06.301: INFO/WeatherClockWidgetProvider(582): changeFtoC 
01-10 11:01:06.311: INFO/WeatherClockWidgetProvider(582): updateDate 
01-10 11:01:06.311: INFO/WeatherClockWidgetProvider(582): setCalendarInstance 
01-10 11:01:06.311: INFO/WeatherClockWidgetProvider(582): updateWeatherDescription 
01-10 11:01:06.321: INFO/WeatherClockWidgetProvider(582): updateUpdatedTime 
01-10 11:01:06.321: INFO/WeatherClockWidgetProvider(582): setCalendarInstance 
01-10 11:01:06.341: ERROR/updateUpdatedTime dateString(582): 1/10/2012 
01-10 11:01:06.371: ERROR/updatedTime before(582): Update: JAN.10 9:10 AM 
01-10 11:01:06.371: ERROR/updatedTime end(582): Update: JAN.10 9:10 AM 
01-10 11:01:06.441: INFO/WeatherClockWidgetProvider(582): bindViews 
01-10 11:01:06.441: INFO/WeatherClockWidgetProvider(582): appWidgetId = 3 
01-10 11:01:06.501: INFO/System.out(8418): waiting for debugger to settle... 
01-10 11:01:06.701: INFO/System.out(8418): waiting for debugger to settle... 
01-10 11:01:06.909: INFO/System.out(8418): waiting for debugger to settle... 
01-10 11:01:07.110: INFO/System.out(8418): waiting for debugger to settle... 
01-10 11:01:07.311: INFO/System.out(8418): debugger has settled (1316) 
01-10 11:01:07.501: ERROR/gralloc(126): [unregister] handle 0x6335d0 still locked (state=40000001) 
01-10 11:01:08.931: INFO/ActivityManager(126): Displayed activity com.PecAppsRadio/.tabs: 4886 ms (total 4886 ms) 
01-10 11:02:00.091: INFO/WeatherClockWidgetProvider(582): updateAllElements 
01-10 11:02:00.091: INFO/WeatherClockWidgetProvider(582): updateTime 
01-10 11:02:00.091: INFO/WeatherClockWidgetProvider(582): setCalendarInstance 
01-10 11:02:00.091: INFO/WeatherClockWidgetProvider(582): onTimeChanged 
01-10 11:02:00.091: INFO/WeatherClockWidgetProvider(582): mHour01HandIndex = 1 
01-10 11:02:00.091: INFO/WeatherClockWidgetProvider(582): mHour01HandIndex = 1 
01-10 11:02:00.091: INFO/WeatherClockWidgetProvider(582): mHour01HandIndex = 0 
01-10 11:02:00.091: INFO/WeatherClockWidgetProvider(582): mHour01HandIndex = 2 
01-10 11:02:00.091: INFO/WeatherClockWidgetProvider(582): updateTime id = 3 
01-10 11:02:00.091: INFO/WeatherClockWidgetProvider(582): updateCurrentTemperature 
01-10 11:02:00.091: INFO/WeatherClockWidgetProvider(582): changeFtoC 
01-10 11:02:00.111: INFO/WeatherClockWidgetProvider(582): updateCurrentLocal 
01-10 11:02:00.111: INFO/WeatherClockWidgetProvider(582): updateTemperatures 
01-10 11:02:00.121: INFO/WeatherClockWidgetProvider(582): setCalendarInstance 
01-10 11:02:00.131: INFO/WeatherClockWidgetProvider(582): highT = 48 
01-10 11:02:00.131: INFO/WeatherClockWidgetProvider(582): lowT = 43 
01-10 11:02:00.131: INFO/WeatherClockWidgetProvider(582): changeFtoC 
01-10 11:02:00.141: INFO/WeatherClockWidgetProvider(582): changeFtoC 
01-10 11:02:00.151: INFO/WeatherClockWidgetProvider(582): updateDate 
01-10 11:02:00.151: INFO/WeatherClockWidgetProvider(582): setCalendarInstance 
01-10 11:02:00.161: INFO/WeatherClockWidgetProvider(582): updateWeatherDescription 
01-10 11:02:00.161: INFO/WeatherClockWidgetProvider(582): updateUpdatedTime 
01-10 11:02:00.161: INFO/WeatherClockWidgetProvider(582): setCalendarInstance 
01-10 11:02:00.171: ERROR/updateUpdatedTime dateString(582): 1/10/2012 
01-10 11:02:00.171: ERROR/updatedTime before(582): Update: JAN.10 9:10 AM 
01-10 11:02:00.171: ERROR/updatedTime end(582): Update: JAN.10 9:10 AM 
01-10 11:02:00.201: INFO/WeatherClockWidgetProvider(582): bindViews 
01-10 11:02:00.201: INFO/WeatherClockWidgetProvider(582): appWidgetId = 3 

java代码读取包含tabhost和tabwidget控制xml文件:

public class tabs extends Activity{ 


     protected void onCreate(Bundle savedInstanceState) { 

      super.onCreate(savedInstanceState); 
      setContentView(R.layout.tabmain); 

      TabHost tabs=(TabHost)findViewById(R.id.tabhost); 

      tabs.setup(); 

      TabHost.TabSpec spec=tabs.newTabSpec("tag1");  
      spec.setContent(R.id.tab1); 
      spec.setIndicator("tab1"); 
      tabs.addTab(spec); 

      spec=tabs.newTabSpec("tag2"); 
      spec.setContent(R.id.tab2); 
      spec.setIndicator("tab2"); 
      tabs.addTab(spec); 

      spec=tabs.newTabSpec("tag3"); 
      spec.setIndicator("Favourites", getResources().getDrawable(R.drawable.favourites_star)); 
      spec.setContent(new Intent(this,RadioAppActivityGroup.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)); 
      tabs.addTab(spec); 

     } 


    private class RadioAppActivityGroup extends ActivityGroup{ 


     protected void onCreate(Bundle savedInstanceState) { 

      super.onCreate(savedInstanceState); 

      View view = getLocalActivityManager().startActivity("radiotabs", new 
      Intent(this, favourites.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)).getDecorView(); 

      this.setContentView(view); 


     } 



    } 


} 

XML代码方含的tabhost和布局控制:

<?xml version="1.0" encoding="utf-8"?> 
<TabHost xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/tabhost" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
    <LinearLayout 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
    <TabWidget android:id="@android:id/tabs" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
    /> 
    <FrameLayout android:id="@android:id/tabcontent" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent"> 

     <LinearLayout 
     android:id="@+id/tab1" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:orientation="vertical"/> 

     <LinearLayout 
     android:id="@+id/tab2" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:orientation="vertical"/> 

     <LinearLayout 
     android:id="@+id/tab3" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:orientation="vertical"/> 

    </FrameLayout> 
    </LinearLayout> 
</TabHost> 

回答

0

而不是调用tabs.setup的();

试试下面的那个地方

LocalActivityManager mLocalActivityManager = new LocalActivityManager(this, false); 
    mLocalActivityManager.dispatchCreate(savedInstanceState); 
    tabs.setup(mLocalActivityManager); 

线同时,尽量使RadioAppActivityGroup独立的类继承的ActivityGroup,而不是使其成为私有内部类,并在清单ASLO定义它。