这是我的代码:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_hangman_guess);
TextView t = (TextView) findViewById(R.id.lives);
String s = "";
for (int i = 0; i < WordHandler.lives; i++) // Error on this line
s += new String(Character.toChars(0x2764));
t.setText(s);
}
当我运行此代码时,我在注释行上得到java.lang.ExceptionInInitializerError
,这是由以下行的android.content.res.Resources$NotFoundException
引起的:
public static String word = Resources.getSystem().getString(R.string.default_word);
变量WordHandler.lives
定义为public static int lives = 5;
为什么抛出此异常?我不能拨打Resources.getSystem()
吗?