私のアプリは、4 つのタブを持つ TabActivity で起動し、それぞれのコンテンツとして ListView アクティビティが関連付けられています。理想的には、Drupal XMLRPC 接続を初期化する onCreate で AsyncTask を起動し、それが完了したら、tabHost を作成し、onPostExecute にタブを追加したいと考えています。これは Android 2.2 以降では問題なく動作しますが、2.2 以前ではすぐに強制終了します。私が読んだことから、Android 2.2 では、TabActivity は、AsyncTasks を含む他の何かが行われる前にタブを作成する必要があるようです? setCurrentTab でアクティビティを開始する前に AsyncTask を実行する TabActivity を実装する方法について誰か提案があれば、私は最も感謝しています。これは、私が使用している onCreate であり、参照用に tabHost を初期化します。
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
tabHost = getTabHost(); //The activity TabHost
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title_bar);
TabHost.TabSpec spec; //Reusable 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, BlogList.class);
// Initialize a TabSpec for each tab and add it to the TabHost
spec = tabHost.newTabSpec("Blog Posts").setIndicator("Blog Posts")
.setContent(intent);
tabHost.addTab(spec);
// Do the same for the other tabs
intent = new Intent().setClass(this, DiariesList.class);
spec = tabHost.newTabSpec("Diaries").setIndicator("Diaries")
.setContent(intent);
tabHost.addTab(spec);
intent = new Intent().setClass(this, BoardList.class);
spec = tabHost.newTabSpec("MGoBoard").setIndicator("MGoBoard")
.setContent(intent);
tabHost.addTab(spec);
intent = new Intent().setClass(this, UserActivityList.class);
spec = tabHost.newTabSpec("My Account").setIndicator("My Account")
.setContent(intent);
tabHost.addTab(spec);
tabHost.getTabWidget().getChildAt(0).getLayoutParams().height = 50;
tabHost.getTabWidget().getChildAt(1).getLayoutParams().height = 50;
tabHost.getTabWidget().getChildAt(2).getLayoutParams().height = 50;
tabHost.getTabWidget().getChildAt(3).getLayoutParams().height = 50;
tabHost.setCurrentTab(0);
}