在类名为Opciones的异步任务中获取内容。不知道具体步骤,我看过一些代码:
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
请高手解惑,谢谢
需要满足条件:
1.使用AsyncTask要在其他类比如MyCustomTask进行extend
2.在新类的构造器中,传递context
举个例:
public class MyCustomTask extends AsyncTask<Void, Void, Long> {
private Context mContext;
public MyCustomTask (Context context){
mContext = context;
}
//other methods like onPreExecute etc.
protected void onPostExecute(Long result) {
Toast.makeText(mContext,"Subiendo la foto. ¡Tras ser moderada empezara a ser votada!: ", Toast.LENGTH_LONG).show();
}
}
对类进行实例化:
MyCustomTask task = new MyCustomTask(context);
task.execute(..);
没有创建实例吧,应该是需要继承AsyncTask