【发布时间】:2013-05-31 00:46:52
【问题描述】:
我正在尝试在名为 Opciones 的类的 AsyncTask 中获取上下文(该类是唯一调用该任务的类),但我不知道该怎么做,我看到了一些这样的代码:
protected void onPostExecute(Long result) {
Toast.makeText(Opciones.this,"Subiendo la foto. ¡Tras ser moderada empezara a ser votada!: ", Toast.LENGTH_LONG).show();
}
但它对我不起作用它说:"No enclosing instance of the type Opciones in scope"
【问题讨论】:
-
Opciones 是一项活动吗?如果没有,您需要将上下文传递给该类,然后在
AsyncTask中使用它 -
这看起来像是一个答案stackoverflow.com/questions/45653121/…
标签: android android-asynctask toast android-context