为什么这个调用栈如此怪异? [英] Why is this call stack so weird?

查看:95
本文介绍了为什么这个调用栈如此怪异?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Today I was debugging my android app and it crashes. Here is the call stack:

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)

然后,我单击行号链接(TextView.java:3860),将我带到一行Javadoc注释.我真的很困惑.注释从不被执行.没错这很奇怪.

Then I clicked on the line number links (TextView.java:3860) and it took me to a line of javadoc comment. I was really confused. Comments never get executed. That can't be wrong. This is strange.

这是我的代码:

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);
}

tvHighscore.setText(Game.getInstance().getHighscore()); 引用调用堆栈中的行:com.whackanandroid.GameActivity.gameOver(GameActivity.java:68).我认为可能是因为tvHighscore的父视图是 LinearLayout GONE .这有关系吗?还是我做错了其他事情?

The line tvHighscore.setText (Game.getInstance ().getHighscore ()); refers to the line in the call stack: at com.whackanandroid.GameActivity.gameOver(GameActivity.java:68). I think it might be because tvHighscore's parent view, a LinearLayout is GONE. Does this matter? Or did I do anything else wrong?

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

If you need to see more code, feel free to ask me.

推荐答案

还是我做错了其他事情?

Or did I do anything else wrong?

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

Yes. You called setText(int), with a value that is not a string resource ID. Change:

tvHighscore.setText (Game.getInstance ().getHighscore ());

收件人:

tvHighscore.setText(Integer.toString(Game.getInstance().getHighscore()));

这篇关于为什么这个调用栈如此怪异?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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