在catch块中使用时吐司不显示
-
27-09-2019 - |
题
我注意到,当它是一个catch块内使用不显示举杯。 有谁知道捕获异常时,如何显示祝酒词?一个示例:
try {
// try to open a file
} catch (FileNotFoundException e) {
Toast.makeText(this, R.string.txt_file_not_found, Toast.LENGTH_LONG);
return; // cancel processing
}
解决方案
应该是这样的:
Toast toast = Toast.makeText(this, R.string.txt_file_not_found, Toast.LENGTH_LONG);
toast.show();
其他提示
是,我把它现有的线后面右:
Toast.makeText(this, R.string.txt_file_not_found, Toast.LENGTH_LONG).show();
不隶属于 StackOverflow