`
enki_ding
  • 浏览: 211154 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

android.app.SuperNotCalledException did not call through to supper onCreate()的问题

 
阅读更多

写了一个简单的例子,就是从一个activity跳转到另一个activity,一个叫LoginDemoActivity,加一个叫NoteActiviy。跳转的代码段如下:

btnLogin=(Button)findViewById(R.id.btnLogin);
        btnLogin.setOnClickListener(new Button.OnClickListener(){

            public void onClick(View v) {
                if("xxxx@126.com".equals(account.getText().toString().trim())
                        && "xxxxxxxxxxx".equals(password.getText().toString().trim())){
                    Intent intent=new Intent();
                    intent.setClass(LoginDemoActivity.this, NoteActivity.class);
                    startActivity(intent);
                    LoginDemoActivity.this.finish();
                }else{
                    Toast.makeText(LoginDemoActivity.this, "输入的帐号或密码有误!", Toast.LENGTH_LONG).show();
                }
            }
           
        });

 

在NoteActivity的代码如下:

protected void onCreate(Bundle savedInstanceState) {
       
        setContentView(R.layout.note);
        btnClose=(Button)findViewById(R.id.btnClose);
        btnClose.setOnClickListener(new Button.OnClickListener(){

            public void onClick(View v) {
                NoteActivity.this.finish();
            }
           
        });
    }

在AndroidMainfest.xml中已经注册了这两个activity。

 

但当程序运行起来时,抛出如下异常:

android.app.SuperNotCalledException did not call through to supper onCreate();

 

Google了一把,原来是在NoteActivity的onCreate()函数中没有加super.onCreate(savedInstanceState);

修改代码后,运行正常,修改后的代码为:

protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.note);
        btnClose=(Button)findViewById(R.id.btnClose);
        btnClose.setOnClickListener(new Button.OnClickListener(){

            public void onClick(View v) {
                NoteActivity.this.finish();
            }
           
        });
    }

注意红色高亮处!

分享到:
评论
2 楼 鲁迪尼 2013-12-02  
你真是帮了大忙了,头疼了好几天了,给你鞠个躬
1 楼 songhaikang 2013-03-14  
我加了还是不行啊

相关推荐

    redis-desktop-manager 2020.2.0.0 不支持SSH

    标题中的“redis-desktop-manager 2020.2.0.0 不支持SSH”表明这是一个关于Redis Desktop Manager的讨论,具体版本为2020.2.0.0,而该版本的一个主要缺点是它不支持通过Secure Shell (SSH)进行连接。...

    一般过去时练习.docx

    3. Did you go to the Great Wall last year? 4. What day was it yesterday? 5. The old man was ill and went to see a doctor. 6. We had a party last night. 7. We visited the museum and went home. 8. — ...

    一般过去时小学练习题.docx

    3. Did you go to the Great Wall last year? 4. What day was it yesterday? 5. The old man was ill and went to see a doctor. 6. We had a party last night. 7. We visited the museum and went home. 8. How ...

    一般过去式专练.pdf

    16. There _were_ not enough people to pick apples that day. (复数形式的 be 动词过去式是 were) 17. There _weren't_ any hospitals in my hometown in 1940. (复数形式的否定,weren't) 18. There _was_ enough...

    山东省诸城市密州街道卢山初中2016届中考英语专题复习一般过去时测试题

    3. _Did_ you _go_ (go) to the Great Wall last year? 4. What day _was_ (be) it yesterday? 5. The old man _was_ (be) ill and went to see a doctor. 6. We _had_ (have) a party last night. 7. We _visited_ ...

    小学一般过去时练习题集(课后练习).doc

    3. 用过去式填空:在句子中正确使用过去式能表达过去的行为,如"We enjoyed ourselves at the party last night.","Jack studied for the English test last Sunday.","Did you go to the Great Wall last year?...

    2021-2022年收藏的精品资料中考英语总复习句型转换专项练.doc

    5. Do you want to go out for a walk after supper? (Shall we...? 可以转换为Do you want to...? 提出建议) 6. When she was four years old, she began to learn dancing. (at the age of 可以换成when引导的...

    九年级英语上Unit语法used to do 用法PPT课件.pptx

    - Lucy is/gets used to walking after supper.(露西习惯于晚饭后散步。) - Wood is used to make paper.(木头被用来造纸。) - Mrs. Green has been/got used to eating with chopsticks.(格林夫人已经习惯了用...

    九年级英语上Unit语法used to do 用法PPT学习教案.pptx

    `Lucy (is/gets used to walking) after supper.` - 正确答案:`is/gets used to walking` - 9. `Wood (is used to make) paper.` - 正确答案:`is used to make` - 10. `Mrs. Green (has got/has been used to...

    Android代码-SupperShape

    通过封装GradientDrawable、StateListDrawable 、LayerDrawable 代替每次都需要...How to: Step 1. Add the JitPack repository to your build file Add it in your root build.gradle at the end of repositories:

    初中英语固定搭配.ppt

    8. **Call sb. (sth.)** 把某人称为...,或者称呼某事物为... 9. **Would like sb. to do sth.** 表达愿意让某人做某事,带有客气的语气。 10. **Why don’t you do sth.?** 或 **Why not do sth.?** 提出建议的...

    APP_UI.rar

    element=driver.find_elemen_by_android_uiautomator(selector) elif by == 'xpath': element=driver.find_element_by_xpath(selector) else: raise NameError return element @staticmethod def tap...

    supper pi CPU 测试软件

    supper pi 是用来测试CPU浮点运算性能的软件

    初中英语常考句型62例大集合.doc

    才...”,He didn’t have supper until his parents came back. 指出他直到父母回来才吃晚饭。 10. **比较级 + and + 比较级** 表示程度逐渐加深,The baby cried harder and harder. 描述婴儿的哭声越来越大。 ...

    2021年中考英语句型知识点汇总-中考英语必考知识点.pdf

    (not) to do sth.:请求某人做(不做)某事。 30. show sb. sth./show sth. to sb.:给某人看某物。 31. introduce sb. to sb./introduce sb. to sth.:向某人介绍某人或某物。 32. let sb. do sth./let sb. not do...

    学学Python_44类的成员03 supper函数

    3.0以后可用supper函数,继承父类构造函数。对应文件:ClassElement3。文件:https://blog.csdn.net/yysyangyangyangshan/article/details/84350818

    全套人教版九年级英语Unit 4同步练习题及答案16精选.doc

    - be used to do sth.:被用来做某事,例如:"She is used to walking after supper."(她被用来晚饭后散步。) - be used for (doing) sth.:被用作做某事,例如:"Wood is used for making paper."(木头被用来...

    62个初中英语写作最常用句型.docx

    才...”,如"He didn't have supper until his parents came back." 描述条件与结果的关系。 10. **比较级+and+比较级**:表示程度逐渐增强,如"The baby cried harder and harder." 形象地描绘变化过程。 11. **...

    江苏省南通市实验中学八年级下学期3月月考英语试题.pdf

    10. 一般过去时态的疑问句:when引导的一般疑问句,动词用过去式,且助动词用did,如"When did you join the League?" 11. 反义疑问句:陈述句部分为肯定,反问部分用否定;反之,陈述句部分为否定,反问部分用肯定...

    2020_2021学年高中英语Unit5TravellingabroadSectionⅡ_LearningaboutLangua

    - 原句:He did as much as he could to help me. 改写:He did everything he could to help me. - 原句:Fix your attention on getting the general idea. 改写:Concentrate on getting the general idea. ...

Global site tag (gtag.js) - Google Analytics