java.lang.RuntimeException: Unable to start activity ComponentInfo
2013-09-13 21:06
639 查看
异常:java.lang.RuntimeException: Unable to start activity ComponentInfo{com.william/com.william.ResultActivity}: android.content.res.Resources$NotFoundException: String resource ID #0x14
解决:TextView 对象中有一个方法为setText(param) ,当你传入一个int类型的值时,代码是不会报错的,但是当你运行着程序的时候,就会报出上面的错误。上网查了一些资料,最后知道为什么会有这样的错误出现,因为这是由于Android 会认为你传入的 int 型的数值是某个 resource 的 id ,那运行时就会出错。
myResult.setText(lastValue+"")代码,如果只myResult.setText(lastValue)写的话,那么这个lastValue值就是一个int类型的值了,那么只需要在后面加上一个空的字符串就可以了。
==================
但是我并无以上网友介绍的问题,我的问题是:
intent = new Intent(PerformanceTestMainActivity.this, PrinterTestActivity.class);
this.startActivity(intent);
就因为这个。唉,什么原理?
解决:TextView 对象中有一个方法为setText(param) ,当你传入一个int类型的值时,代码是不会报错的,但是当你运行着程序的时候,就会报出上面的错误。上网查了一些资料,最后知道为什么会有这样的错误出现,因为这是由于Android 会认为你传入的 int 型的数值是某个 resource 的 id ,那运行时就会出错。
myResult.setText(lastValue+"")代码,如果只myResult.setText(lastValue)写的话,那么这个lastValue值就是一个int类型的值了,那么只需要在后面加上一个空的字符串就可以了。
==================
但是我并无以上网友介绍的问题,我的问题是:
intent = new Intent(PerformanceTestMainActivity.this, PrinterTestActivity.class);
this.startActivity(intent);
就因为这个。唉,什么原理?
相关文章推荐
- Android开发中java.lang.RuntimeException: Unable to start activity ComponentInfo{xxx}
- Android Studio java.lang.RuntimeException: Unable to start activity ComponentInfo
- java.lang.RuntimeException:Unable to start activity ComponentInfo{com.meizu.beautify/com.my.viewc.Ma
- java.lang.RuntimeException: Unable to start activity ComponentInfo{com.wwj.toggle/com.wwj.toggle.Set
- 错误:java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.tongzhi
- java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ex.activity/com.ex.activity.LoginActivity}: android.view.InflateException: Binary XML file line #1: Error inflating class
- Android 自定义View java.lang.RuntimeException: Unable to start activity ComponentInfo
- java.lang.RuntimeException: Unable to start activity ComponentInfo{}:java.lang.NullPointerException
- Android开发中java.lang.RuntimeException: Unable to start activity ComponentInfo{xxx}: java.lang.NullPoi
- android中使用fragment时出现如下错误 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.fra
- 第一个HelloWorld程序,遇到java.lang.RuntimeException: Unable to start activity ComponentInfo
- java.lang.RuntimeException: Unable to start activity ComponentInfo{com.hbsjz/com.hbsjz.BaseMapActivity}:
- Java.lang.RuntimeException: Unable to start activity ComponentInfo{*}
- java.lang.RuntimeException: Unable to start activity ComponentInfo{com.clm.activity/com.clm.activity
- Android开发中java.lang.RuntimeException: Unable to start activity ComponentInfo{xxx}: java.lang.NullPointerException 错误的集中原因及解决办法
- Android开发中java.lang.RuntimeException: Unable to start activity ComponentInfo{xxx}: java.lang.NullPoi
- java.lang.RuntimeException: Unable to start activity ComponentInfo{com.clm.activity/com.clm.activity
- 【安卓学习问题日志】java.lang.RuntimeException: Unable to start activity ComponentInfo{org.wm.demo/org.wm.demo
- andriod中使用xutils出现java.lang.RuntimeException: Unable to start activity ComponentInfo
- java.lang.RuntimeException: Unable to start activity ComponentInfo解决方案