获取资源的数量...&QUOT值时没有包装标识;轰然由于QUOT&;标识、数量、资源、QUOT

2023-09-04 09:06:13 作者:岑寂

通过,我能找到关于这一主题的各个线程搜索和尝试一切,似乎工作,为别人好了后,我还屈服于需要发布自己的问题。

Okay after searching through the various threads that I could find on this topic, and trying everything that seemed to work for the others... I have succumb to the need to post my own issue.

作为一个总的小白到Android和Java,你将不得不原谅,需要跟我说话像个孩子:)

As a total noob to Android and Java, you will have to forgive the need to talk to me like a child :)

我有一个应用程序,有3个活动至今。这可以作为一个导航画面主窗口中选择其他两个中的一个。第一个完美的作品,但是当我尝试按钮数量2 ...崩溃。

I have an app that has 3 activities so far. A main window that works as a navigation screen to choose one of the other two. The first works perfectly, but when I try button number 2... it crashes.

我有一些code,我试图运行的onCreate ......所以当我看到它,往往会导致崩溃的XML布局..我注释掉了Java code ...和preSTO布局负荷罚款。

I have some code that I am trying to run onCreate... so when I saw that it was often the XML layout that caused the crash.. I commented out the Java code... and presto the layout loads fine.

把code回来,它再次崩溃。

putting the code back in, it crashes once again.

展望LogCat中我看到这样一行无包装标识中获得价值的资源数量0x0000000d当

Looking in LogCat I see a line that says "No Package identifier when getting value for resource number 0x0000000d"

于是各种有关致命异常和关闭虚拟机行。

Then all sorts of lines about fatal exceptions and shutting down the VM.

所以,从赢得其他职位的信心,我去R.java文件,看看有什么资源都有ID ......这不是在那里。他们都开始与0x7F的......现在是唯一一个在D结尾是ID为game_Answer1一个TextView。但我不能肯定,如果这是它指的是与否。

So, garnering confidence from other posts, I went to the R.java file to see what resource has that ID... and it's not in there. They ALL start with 0x7f... now the ONLY one that ends in "d" is a textview with the ID "game_Answer1". But I am not certain if that is what it's referring to or not.

我也尝试了Eclipse干净的命令,以及删除R.java ......同样的问题。

I did try the Eclipse clean command, as well as deleting the R.java... same issue.

下面是java code,这似乎是崩溃......再次,保持笑声在我的意大利面条code,因为这是在Java中尝试#2超出一个Hello World的应用程序!

Below is the java code that seems to be crashing... again, hold the laughter at my spaghetti code as this is attempt #2 in Java beyond a hello world app!

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
import java.util.Random;
public class playgame extends Activity {


/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.gamelayout);

    //set up first question
    genQuestion();

}


Random generator = new Random();

public void genQuestion() {
    int i = generator.nextInt(25);
    int correct = generator.nextInt(2)+1;
    TextView g_answera = (TextView) findViewById(R.id.game_Answer1);
    TextView g_answerb = (TextView) findViewById(R.id.game_Answer2);
    TextView g_answerc = (TextView) findViewById(R.id.game_Answer3);


    g_answera.setText("-");
    g_answerb.setText("-");
    g_answerc.setText("-");

    if(correct==1){
        g_answera.setText("!");
    }
    if(correct==2){
        g_answerb.setText("!");
    }
    if(correct==3){
        g_answerc.setText("!");
    }

}

下面是与此问题相关的XML布局......万一我失去了一些东西很明显的:

Below is the XML layout associated with this issue... just in case I am missing something obvious:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" android:background="#ffffff"  android:id="@+id/gamelayoutwrapper">
<RelativeLayout android:layout_height="wrap_content" android:id="@+id/games_animalnameFrame" android:layout_width="fill_parent" android:gravity="right">
    <TextView android:layout_height="wrap_content" android:id="@+id/game_animalname" android:layout_width="fill_parent" android:textSize="60sp" android:layout_alignParentRight="true" android:gravity="right" android:text="__nteater"></TextView>
</RelativeLayout>
<RelativeLayout android:layout_width="wrap_content" android:id="@+id/game_animalimageFrame" android:layout_below="@+id/games_animalnameFrame" android:layout_centerInParent="true" android:layout_height="wrap_content" android:gravity="top">
    <ImageView android:id="@+id/game_animalImage" android:src="@drawable/elephant" android:scaleType="fitCenter" android:layout_width="fill_parent" android:layout_height="fill_parent" android:paddingBottom="10dp"></ImageView>
</RelativeLayout>
<RelativeLayout android:layout_height="wrap_content" android:id="@+id/gameLettersFrame" android:layout_alignParentBottom="true" android:layout_width="fill_parent" android:layout_centerHorizontal="true" android:background="#cccccc">

            <TextView android:layout_height="wrap_content" android:id="@+id/game_Answer1" android:text="A" android:paddingLeft="20dp" android:paddingRight="20dp" android:layout_gravity="left" android:clickable="true" android:textSize="100sp" android:layout_width="wrap_content" android:layout_alignParentLeft="true" android:textColor="#090999" android:background="#ccccFF"></TextView>
            <TextView android:layout_height="wrap_content" android:id="@+id/game_Answer2" android:text="B" android:paddingLeft="20dp" android:paddingRight="20dp" android:layout_gravity="center_horizontal" android:clickable="true" android:textSize="100sp" android:layout_width="wrap_content" android:layout_centerInParent="true" android:textColor="#090999" android:background="#ffcccc"></TextView>
            <TextView android:layout_height="wrap_content" android:id="@+id/game_Answer3" android:text="C" android:paddingLeft="20dp" android:paddingRight="20dp" android:layout_gravity="right" android:clickable="true" android:textSize="100sp" android:layout_width="wrap_content" android:layout_alignParentLeft="false" android:layout_alignParentRight="true" android:textColor="#090999" android:background="#ccffcc"></TextView>

</RelativeLayout>

推荐答案

我在不久前遇到了同样的问题,我认为它是固定的,但我想通了备选答案总是欢迎:)如果使用的setText()方法,你不能发送通过原始数据类型,如int和double,而转换为字符串,然后通过发送字符串。这个固定我的问题,当它突然出现了

I ran into this same issue a while ago, I assume that it is fixed but I figured an alternative answer is always welcome :) When using the setText() method you CANNOT send through primitive data types such as int and double, rather convert to string and then send through the string. This fixed my issue when it popped up