写了一个简单的例子,就是从一个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.— taking a walk after supper? — Good idea. A. How about B. Why not C. Could we 3.— Excuse me. Can you spare me a few minutes? — ________ A. What’s on? B.What’s up? C.What is it? 4.— Look, it...
通过封装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:
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浮点运算性能的软件
java中this和supper关键字的详细区分
3.0以后可用supper函数,继承父类构造函数。对应文件:ClassElement3。文件:https://blog.csdn.net/yysyangyangyangshan/article/details/84350818
I did not mean to hurt you. A:Excuse me B:I won't regret C:I'm really sorry D:That's all right 25、- I've heard that you are going to Thailand? - Yes, I'll leave on Sunday. - That's great! _____...
不可以用加QQ770514992 骂我
Combined with RxJava , Supper observer pattern to get result Compatible with Android 7.0 Custom Image Loader Preview Use Glide 1.Add gradle: compile 'com.caimuhao:rxpicker:1.1.5' 2.Extends ...
三年级英语LessonF_What’s_for_Supper课件.ppt
hight power supper ic
Supper 还对打包部署到 Android 提供实验性支持。 包含 Sparho 基本搜索 API 的公开演示版本位于: ://supper-demo.herokuapp.com 目前是一个工作模型,从内部项目概括出来,边缘仍然有点粗糙。 现在,将其视为...
程序比较软件,supper compare
五年级英语下册 Unit 1 Lesson 5Making supper(1)教案 冀教版.doc
Michal在CVPR上的经典文章+源代码,由多张低分辨率图片超分得到高分辨率图片。图片要求tif格式,9张。已运行成功。
My Develop zbar app
java反编译工具-超级强!.rar
提高高校高水平运动员文化成绩之探索——以中国药科大学高水平运动队SUPPER“n 1”互助组合为例.pdf
Android 上最快的数据备份工具!您可以将应用程序和联系人,短信和通话记录,书签和日历备份到 SD 卡/Gmail。您再也不会丢失数据!这是超级备份的免费无广告版本,如果您需要经常对手机系统中的重要数据进行备份,您...
一款制作曲线的插件 , 要求3.5版本以后 有意者可下载学习