2

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.

4

3 回答 3

11

android.content.res.Resources$NotFoundException:字符串资源 ID #0x16

您正在尝试设置int

tetview.setText()Toast.makeText(),它将作为字符串资源 id。

所以试着像这样给 int 值

.setText(""+intvalue)或者Toast.makeText(context,""+intvalue,..)

于 2013-04-22T11:01:17.140 回答
0

我通过重新安装 Android SDK 解决了“找不到资源”异常。出于某种原因,在打包 apk 时,SDK 工具没有打包资源。它是一个构建错误(静默错误),仅在运行时大喊大叫。我不需要重新安装 JDK 或 Eclipse。

于 2014-10-26T17:42:21.920 回答
-1
  1. 尝试清理到项目以重建 R.java

  2. 通过创建一个新的 xml 来重建 xml,我猜你可能忘记添加命名空间(xmlns:android="http://schemas.android.com/apk/res/android")

    希望我能帮上忙。

于 2013-04-22T11:08:23.940 回答