当我切换到新选项卡时,Android Tabs崩溃

问题描述:

请检查我在android选项卡中做了什么错误。每当我切换到另一个选项卡时,应用程序同时崩溃。当我切换到新选项卡时,Android Tabs崩溃

下面是完整的源代码:http://dl.dropbox.com/u/16910648/Phase1.zip

+1

你会得到什么错误? –

如何包装在一个try/catch东西可看的异常消息说什么?我做了类似的事情,这里是对我有用的东西:

try { 

    final TabHost tabHost = getTabHost(); 

    tabHost.addTab(tabHost.newTabSpec("tab1") 
     .setIndicator(mContext.getString(R.string.tab_label_game), res.getDrawable(R.drawable.ic_tab_state)) 
     .setContent(new Intent(this, ActivitySettingsStates.class))); 

    tabHost.addTab(tabHost.newTabSpec("tab2") 
     .setIndicator(mContext.getString(R.string.tab_label_alerts), res.getDrawable(R.drawable.ic_tab_alerts)) 
     .setContent(new Intent(this, ActivitySettingsAlerts.class))); 
} 
catch (Exception ex) { 
    if (DEBUG) Log.e(TAG, PROC + ": Exception occurred: " + ex.toString()); 
}