I am new to Android, Eclipse and partly Java (decade ago I read a Java book and never used it.) I am following this tutorial: http://ofps.oreilly.com/titles/9781449390501/Android_User_Interface.html
I have this code:
public class Status extends Activity implements OnClickListener, TextWatcher {
// ...
class PostToTwitter extends AsyncTask<String, Integer, String> {
// ...
protected void onPostExecute(String result) {
Toast.makeText(Status.this, result, Toast.LENGTH_LONG).show();
}
}
}
I get these errors next to the Toast.makeText line:
- The method makeText(Context, CharSequence, int) in the type Toast is not applicable for the arguments (AsyncTask.Status, String, int)
- No enclosing instance of the type AsyncTask.Status is accessible in scope
- I am not sure why I get an error?
- Why is it mentioning AsyncTask when I am passing the Status activity context?
I guess I am going to slap myself and say Doh! later, but I have starred myself blind at it now 🙂
You problem is that
Statusis a public enum of AsyncTask. So java takes not your activity as a context. Try to hold a instance of your context in yourAsyncTask.Try this code here: