Sunday, January 11, 2015

Android : Toast inside a fragment

Hello,

another tips. I come around an error of

the method getApplicationContext() is undefined

while i try to toast inside a fragment. TO remove the error,simple replace the toast


Toast.makeText(getApplicationContext(), (String)data.result, Toast.LENGTH_LONG).show();
to

Toast.makeText(getActivity(), (String)data.result,
Toast.LENGTH_LONG).show();

Cheers.

No comments:

Post a Comment