【发布时间】:2016-08-03 07:35:05
【问题描述】:
我想在我的 Try/Catch 中使用 Toast,但是当它捕获到错误的输入时,toast 不会出现。我在代码中找不到错误,请在这里帮助我。
这是包含 try/catch 块的代码的一小部分:
else{
try{
Integer.parseInt(score_1.getText().toString());
Integer.parseInt(score_2.getText().toString());
ArrayList_matches.get(position_match).score_1 = score_1.getText().toString();
ArrayList_matches.get(position_match).score_2 = score_2.getText().toString();
adapter.notifyDataSetChanged();
} catch(NumberFormatException ex) {
Toast.makeText(Game_activity.this, "Wrong input, numbers only", Toast.LENGTH_LONG).show();
}
}
【问题讨论】:
-
你应该使用 log.e(tag, message);
标签: android try-catch android-alertdialog toast numberformatexception