Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
260 views
in Technique[技术] by (71.8m points)

android - ERROR No package identifier when getting value for resource number

Both activities are in the same package

Second activity uses second layout file

setContentView(R.layout.main2);

Errors on this line in the Second_Activity.

EditText text1 = (EditText) findViewById(R.id.EditText03);

Here is the layout file for the Second_Activity.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <LinearLayout
        android:id="@+id/LinearLayout01"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >

        <TextView
            android:id="@+id/TextView01"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Answer Is : " >
        </TextView>

        <EditText
            android:id="@+id/EditText03"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >
        </EditText>
    </LinearLayout>

    <Button
        android:id="@+id/Button01"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:onClick="onClick"
        android:text="Calling an intent" >
    </Button>

</LinearLayout>

Here are the errors in the LogCat window

08-01 19:32:20.340: WARN/ResourceType(8875): No package identifier when getting value for resource number 0x00000005
08-01 19:32:20.390: ERROR/AndroidRuntime(8875): Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x5 

mail.xml

<TextView 
    android:id="@+id/TextView01" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" android:text="First Number : ">
</TextView>

<EditText 
    android:id="@+id/EditText01" 
    android:inputType="number"
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content">
</EditText>

<TextView 
    android:id="@+id/TextView02" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" android:text="Second Number: ">
</TextView>

<EditText 
    android:id="@+id/EditText02" 
    android:inputType="number"
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content">
</EditText>

secondscreen.xml

<TextView 
    android:id="@+id/TextView03" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" android:text="Answer Is : ">
</TextView>

<EditText 
    android:id="@+id/main2EditText01" 
    android:inputType="number"
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content">
</EditText>

manifest xml file

    <activity android:name=".ActivityTwo"/>

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I got this same error message when I tried to use TextView.setText passing a char instead of a String. This makes sense since the char would be promoted to an int which meant that I was really calling the

TextView.setText( int resId );

And since there wasn't a resource with that value, it wouldn't work.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...