我注意到,当它是一个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();
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top