我有以下代码:
@Override
protected void onPostExecute(Void arg0) {
...
Toast.makeText(getBaseContext(), getBaseContext().getResources().getString(R.string.toast_sync_completed), Toast.LENGTH_SHORT).show();
}
失败(FC)。如果通过"Test string"
而不是getResources().getString(R.string.toast_sync_completed)
,那么它可以正常运行。我做错了什么?
答案 0 :(得分:11)
将getBaseContext()...更改为getApplicationContext().....
Toast.makeText(getApplicationContext(), getApplicationContext().getResources().getString(R.string.toast_sync_completed), Toast.LENGTH_SHORT).show();
答案 1 :(得分:-1)
试试这段代码
public static void myprofsList(Activity context){
static Context = mConext;
protected void onPostExecute(String result) {
Toast toast=Toast.makeText(mConext,"Succefully Updated Profile Data",Toast.LENGTH_LONG);
}
}
您只需传递字符串文件。