资源未发现异常 [英] Resource not found exception

查看:291
本文介绍了资源未发现异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的项目中使用日期选择器。但只要我运行该项目,它将引发资源未发现异常当我在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() or Toast.makeText(), which it will take as string resource id.

So try to give int value in like this

.setText(""+intvalue) or Toast.makeText(context,""+intvalue,..)

这篇关于资源未发现异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆