AndroidRuntime: did not call through to super.onCreate()

来源:互联网 发布:java oa系统源码下载 编辑:程序博客网 时间:2024/05/14 09:40

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);     }}



0 0
原创粉丝点击