android.content.res.Resurces $ NotFoundException:字符串资源ID#0x0 [英] android.content.res.Resurces$NotFoundException : String resource ID #0x0

查看:50
本文介绍了android.content.res.Resurces $ NotFoundException:字符串资源ID#0x0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请帮助我,我不知道为什么会出现此错误.就在一天前,它起作用了. 我了解它已经存在,并且id存在,但是id在xml中. 它在onCreate方法中给我一个错误:

Please help me, I can't figure out why this error. Just a day ago it worked. I understand the it serches for and id ist'n existing but the id is there in the xml. It give me error here, in onCreate method:

public class DoExamActivity extends Activity {
    private DatabaseHandler db;
    private EditText votoET;
    @Override
    public void onCreate(Bundle savedInstanceState) { 
        super.onCreate(savedInstanceState);
        setContentView(R.layout.do_exam);
        Bundle bundle = getIntent().getExtras();

        db = new DatabaseHandler(getApplicationContext());

        try {
            transcript = new JSONObject(bundle.getString("transcript"));
            exam = new JSONObject(bundle.getString("exam"));
            teacher = new JSONObject(bundle.getString("teacher"));
        } catch (JSONException e) {
            e.printStackTrace();
        }

        votoET = (EditText) findViewById(R.id.examValueET); //here

这是他找不到的编辑文本的do_exam.xml.您可以看到ID在其中!

This is the do_exam.xml of the edit text he cant find. You can see the id is there!

        <TableRow
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal" >

            <ImageView
                android:layout_height="30dp"
                android:layout_gravity="left|center_vertical"
                android:layout_weight="1"
                android:background="@color/ios7orange"
                android:contentDescription="@string/textValueDescr"
                android:src="@drawable/rating_star" />

            <TextView
                android:layout_height="50dp"
                android:layout_weight="1" />

            <EditText
                android:id="@+id/examValueET"
                android:layout_height="40dp"
                android:layout_gravity="center_vertical"
                android:layout_marginRight="10dp"
                android:layout_weight="5"
                android:background="@drawable/rounded_edittext"
                android:hint="@string/examValueHint"
                android:inputType="text"
                android:maxLines="1" />
        </TableRow>

给我这个错误:

11-13 07:04:15.457: E/AndroidRuntime(1091): FATAL EXCEPTION: main
11-13 07:04:15.457: E/AndroidRuntime(1091): java.lang.RuntimeException: Unable to start     activity ComponentInfo{com.utaa.iesami/com.utaa.iesami.activity.DoExamActivity}:     android.content.res.Resources$NotFoundException: String resource ID #0x0
11-13 07:04:15.457: E/AndroidRuntime(1091):     at     android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
11-13 07:04:15.457: E/AndroidRuntime(1091):     at     android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
11-13 07:04:15.457: E/AndroidRuntime(1091):     at     android.app.ActivityThread.access$600(ActivityThread.java:141)
11-13 07:04:15.457: E/AndroidRuntime(1091):     at     android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
11-13 07:04:15.457: E/AndroidRuntime(1091):     at android.os.Handler.dispatchMessage(Handler.java:99)
11-13 07:04:15.457: E/AndroidRuntime(1091):     at     android.os.Looper.loop(Looper.java:137)
11-13 07:04:15.457: E/AndroidRuntime(1091):     at     android.app.ActivityThread.main(ActivityThread.java:5103)
11-13 07:04:15.457: E/AndroidRuntime(1091):     at     java.lang.reflect.Method.invokeNative(Native Method)
11-13 07:04:15.457: E/AndroidRuntime(1091):     at     java.lang.reflect.Method.invoke(Method.java:525)
11-13 07:04:15.457: E/AndroidRuntime(1091):     at     com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
11-13 07:04:15.457: E/AndroidRuntime(1091):     at     com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
11-13 07:04:15.457: E/AndroidRuntime(1091):     at     dalvik.system.NativeStart.main(Native Method)
11-13 07:04:15.457: E/AndroidRuntime(1091): Caused by:     android.content.res.Resources$NotFoundException: String resource ID #0x0
11-13 07:04:15.457: E/AndroidRuntime(1091):     at     android.content.res.Resources.getText(Resources.java:239)
11-13 07:04:15.457: E/AndroidRuntime(1091):     at     android.widget.TextView.setText(TextView.java:3844)
11-13 07:04:15.457: E/AndroidRuntime(1091):     at     com.utaa.iesami.activity.DoExamActivity.onCreate(DoExamActivity.java:61)
11-13 07:04:15.457: E/AndroidRuntime(1091):     at     android.app.Activity.performCreate(Activity.java:5133)
11-13 07:04:15.457: E/AndroidRuntime(1091):     at     android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
11-13 07:04:15.457: E/AndroidRuntime(1091):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
11-13 07:04:15.457: E/AndroidRuntime(1091):     ... 11 more

我在R类中搜索,并且该EditText的ID在其中并且与0不同.那么为什么会出现此错误?

I searched in the R class and the id of that EditText is there and is different from 0. So why this error?

代码已更新

我已经打扫过了,什么也没有.活动太大,我添加了代码,直到出现错误为止.所以我把所有ID都用大写字母,它工作了两个星期,现在只是在那个ET上给了我错误.

I already cleaned, nothing. The activity it's too big, I added the code until the row of the error. So I used the caps for all the IDs, it worked for two week, now it give me error just on that ET.

推荐答案

我的错误.我弄错了行,错误来自必须设置TextView.setText(String.valueOf(int))TextView.setText(int).

My error. I mistaked the rows, the error was from a TextView.setText(int) where I had to set TextView.setText(String.valueOf(int)).

这篇关于android.content.res.Resurces $ NotFoundException:字符串资源ID#0x0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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