我想在我的Try/Catch中使用Toast,但是當它捕捉到錯誤的輸入時,Toast不會顯示出來。我找不到代碼中的錯誤,請在這裏幫助我。Toast in Try/Catch numberformatexception
這其中包括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); – sonnv1368