LA_*_*LA_ 7 resources android toast android-asynctask
我有以下代码:
@Override
protected void onPostExecute(Void arg0) {
...
Toast.makeText(getBaseContext(), getBaseContext().getResources().getString(R.string.toast_sync_completed), Toast.LENGTH_SHORT).show();
}
Run Code Online (Sandbox Code Playgroud)
它失败了(FC).如果通过"Test string"而不是getResources().getString(R.string.toast_sync_completed),那么它可以正常工作.我究竟做错了什么?
Kar*_*iya 11
将getBaseContext()改为getApplicationContext().....
Toast.makeText(getApplicationContext(), getApplicationContext().getResources().getString(R.string.toast_sync_completed), Toast.LENGTH_SHORT).show();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
13388 次 |
| 最近记录: |