为什么这个调用堆栈如此奇怪?

Swe*_*per 0 java android callstack

今天我正在调试我的Android应用程序,它崩溃了.这是调用堆栈:

android.content.res.Resources$NotFoundException: String resource ID #0x8822
        at android.content.res.Resources.getText(Resources.java:246)
        at android.widget.TextView.setText(TextView.java:3860)
        at com.whackanandroid.GameActivity.gameOver(GameActivity.java:68)
        at com.whackanandroid.Game$1.onCountDownFinished(Game.java:79)
        at com.whackanandroid.CountDown$1.run(CountDown.java:23)
        at android.os.Handler.handleCallback(Handler.java:730)
        at android.os.Handler.dispatchMessage(Handler.java:92)
        at android.os.Looper.loop(Looper.java:213)
        at android.app.ActivityThread.main(ActivityThread.java:5225)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:525)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:741)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:557)
        at dalvik.system.NativeStart.main(Native Method)
Run Code Online (Sandbox Code Playgroud)

然后我点击了行号链接(TextView.java:3860),它带我去了一行javadoc评论.我真的很困惑.评论永远不会被执行.这不可能是错的.这很奇怪.

这是我的代码:

public void gameOver () {
    tvScore.setText (Integer.toString (Game.getInstance ().getScore ()));
    tvHighscore.setText (Game.getInstance ().getHighscore ());
    tvScoreText.setVisibility (View.VISIBLE);
    tvScore.setVisibility (View.VISIBLE);

    Animation anim = AnimationUtils.loadAnimation (this, R.anim.cover_fade_in);
    anim.setAnimationListener (new Animation.AnimationListener () {
        @Override
        public void onAnimationStart(Animation animation) {
            GameActivity.this.cover.setVisibility (View.VISIBLE);
        }

        @Override
        public void onAnimationEnd(Animation animation) {
            GameActivity.this.cover.setVisibility (View.VISIBLE);
            Game.InitializeGame (GameActivity.this);
            cover.setVisibility (View.VISIBLE);
        }

        @Override
        public void onAnimationRepeat(Animation animation) {

        }
    });
    cover.startAnimation (anim);
}
Run Code Online (Sandbox Code Playgroud)

该行tvHighscore.setText (Game.getInstance ().getHighscore ());指的是调用堆栈中的行:at com.whackanandroid.GameActivity.gameOver(GameActivity.java:68).我想这可能是因为tvHighscore的父视图,LinearLayoutGONE.这有关系吗?或者我做错了什么?

如果您需要查看更多代码,请随时问我.

Com*_*are 5

或者我做错了什么?

是.您调用setText(int)了一个不是字符串资源ID的值.更改:

tvHighscore.setText (Game.getInstance ().getHighscore ());
Run Code Online (Sandbox Code Playgroud)

至:

tvHighscore.setText(Integer.toString(Game.getInstance().getHighscore()));
Run Code Online (Sandbox Code Playgroud)