写了一个简单的例子,就是从一个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();
}
});
}
注意红色高亮处!
分享到:
相关推荐
标题中的“redis-desktop-manager 2020.2.0.0 不支持SSH”表明这是一个关于Redis Desktop Manager的讨论,具体版本为2020.2.0.0,而该版本的一个主要缺点是它不支持通过Secure Shell (SSH)进行连接。...
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. — ...
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 ...
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...
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_ ...
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?...
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引导的...
- Lucy is/gets used to walking after supper.(露西习惯于晚饭后散步。) - Wood is used to make paper.(木头被用来造纸。) - Mrs. Green has been/got used to eating with chopsticks.(格林夫人已经习惯了用...
`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...
通过封装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:
8. **Call sb. (sth.)** 把某人称为...,或者称呼某事物为... 9. **Would like sb. to do sth.** 表达愿意让某人做某事,带有客气的语气。 10. **Why don’t you do sth.?** 或 **Why not do sth.?** 提出建议的...
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浮点运算性能的软件
才...”,He didn’t have supper until his parents came back. 指出他直到父母回来才吃晚饭。 10. **比较级 + and + 比较级** 表示程度逐渐加深,The baby cried harder and harder. 描述婴儿的哭声越来越大。 ...
(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...
3.0以后可用supper函数,继承父类构造函数。对应文件:ClassElement3。文件:https://blog.csdn.net/yysyangyangyangshan/article/details/84350818
- be used to do sth.:被用来做某事,例如:"She is used to walking after supper."(她被用来晚饭后散步。) - be used for (doing) sth.:被用作做某事,例如:"Wood is used for making paper."(木头被用来...
才...”,如"He didn't have supper until his parents came back." 描述条件与结果的关系。 10. **比较级+and+比较级**:表示程度逐渐增强,如"The baby cried harder and harder." 形象地描绘变化过程。 11. **...
10. 一般过去时态的疑问句:when引导的一般疑问句,动词用过去式,且助动词用did,如"When did you join the League?" 11. 反义疑问句:陈述句部分为肯定,反问部分用否定;反之,陈述句部分为否定,反问部分用肯定...
- 原句: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. ...