android.app.SuperNotCalledException: Activity {com.example.myrelativelayoutproject/com.example.myrelativelayoutproject.Test_TabHost} did not call through to super.onCreate()
初学android 开发 今天遇到该异常苦恼很久 查了资料
源代码: 运行时异常
public class Test_TabHost extends Activity { TabHost mTabHost=null; @Override public void onCreate(Bundle savedInstanceState) { // mTabHost定义在Activity的属性 this.setContentView(R.layout.tabhost); mTabHost = (TabHost) this.findViewById(R.id.tabhost); mTabHost.setup(); TabHost.TabSpec tabWeight = mTabHost.newTabSpec("tab_weight"); tabWeight.setContent(R.id.relativeLayout_weight); tabWeight.setIndicator(getResources().getString(R.string.weight)); mTabHost.addTab(tabWeight); } }
修改后 :运行正常
public class Test_TabHost extends Activity {
TabHost mTabHost=null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// mTabHost定义在Activity的属性
this.setContentView(R.layout.tabhost);
mTabHost = (TabHost) this.findViewById(R.id.tabhost);
mTabHost.setup();
TabHost.TabSpec tabWeight = mTabHost.newTabSpec("tab_weight");
tabWeight.setContent(R.id.relativeLayout_weight);
tabWeight.setIndicator(getResources().getString(R.string.weight));
mTabHost.addTab(tabWeight);
}
}