资源未发现异常 [英] Resource not found exception
问题描述
我想在我的项目中使用日期选择器。但只要我运行该项目,它将引发资源未发现异常当我在XML文件拖动日期选择器会出现以下行
以下类找不到:
- CalendarView(更改为android.widget.CalendarView,修复构建路径,编辑XML)
- 的DatePicker(更改为android.widget.DatePicker,修复构建路径,编辑XML)
logcat的分录如下:
致命异常:了java.lang.RuntimeException:无法启动活动ComponentInfo {com.example.dateandtimepick / com.example.dateandtimepick.MainActivity}:android.content.res.Resources $ NotFoundException:字符串资源ID#0x16
我怎样才能纠正code。先谢谢了。
android.content.res.Resources $ NotFoundException:字符串资源ID#0x16
块引用>您正试图在
设置INT
价值
tetview.setText()
或Toast.makeText()
,这将需要为字符串资源ID。因此,尝试像这样给int值
.setText(+的intValue)
或Toast.makeText(上下文,+的intValue,..)
I am trying to use datepicker in my project. But as soon as I run the project, it throws "Resource not found exception" and following line appears when I drag datepicker in xml file
The following classes could not be found: - CalendarView (Change to android.widget.CalendarView, Fix Build Path, Edit XML) - DatePicker (Change to android.widget.DatePicker, Fix Build Path, Edit XML)
logcat entries are as follows:
FATAL EXCEPTION: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.dateandtimepick/com.example.dateandtimepick.MainActivity}: android.content.res.Resources$NotFoundException: String resource ID #0x16
How can I rectify the code. Thanks in advance.
解决方案android.content.res.Resources$NotFoundException: String resource ID #0x16
You are trying to set
int
value in
tetview.setText()
orToast.makeText()
, which it will take as string resource id.So try to give int value in like this
.setText(""+intvalue)
orToast.makeText(context,""+intvalue,..)
这篇关于资源未发现异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!