开发者

How to use Toast in ASyncTask/onPostExecute with string from resources?

I have the following code:

@Override
protected void onPostExecute(Void arg0) {
                    ...
        Toast.makeText(getBaseContext(), getBaseContext().getResources().getString(R.string.toast_sync_completed), Toast.LENGTH_SHORT).show开发者_如何学Python();
}

It fails (FC). If pass "Test string" instead of getResources().getString(R.string.toast_sync_completed), then it works correctly. What am I doing wrong?


Change getBaseContext()... to getApplicationContext().....

Toast.makeText(getApplicationContext(), getApplicationContext().getResources().getString(R.string.toast_sync_completed), Toast.LENGTH_SHORT).show();


try this code

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);

  }
}

you've to just pass your string file.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜