Android - getIdentifier()抛出Resources $ NotFoundException

时间:2015-04-29 23:32:45

标签: android exception android-resources

我正在为扫雷克隆制作一个简单的评分系统,并在崩溃时不断获取Resources $ NotFoundException。我很确定它是导致它的getIdentifier函数,而且我过去只有这个函数的麻烦。我做错了什么?

提前致谢。

private void doScoring()
{
    SharedPreferences sp = this.getSharedPreferences("scores", Context.MODE_PRIVATE);
    int score = (int) Math.ceil(1000/this.getIntent().getExtras().getDouble("time"));
    int[] scores = new int[10];
    String[] names = new String[10];
    int newOffset = 0;
    for(int i = 0; i < 10; i++)
    {
        if(sp.getInt("s"+i,999)>score&&newOffset==0)
        {
            newOffset++;
            names[i] = "Prompted Name";
            scores[i] = score;
        }
        scores[i] = sp.getInt("s"+(i-newOffset), 999);
        names[i] = sp.getString("n"+(i-newOffset), "No Score");
        ((TextView) this.findViewById(getResources().getIdentifier("score_name_"+(i+1), "id", "edu.laura.omc_prototype"))).setText(scores[i]);
        ((TextView) this.findViewById(getResources().getIdentifier("score_"+(i+1), "id", "edu.laura.omc_prototype"))).setText(names[i]);
    }
}

0 个答案:

没有答案