android:方法一旦置于asynctask中就停止工作

时间:2011-06-15 05:03:51

标签: android android-asynctask

我有一个方法来填充drawables的公共ArrayList。

这很好用(伪代码):

 - populateArrayList()
 - use imageAdapter to populate gridview

现在我想将populateArrayList()方法放入asynctask中以移出UI线程并显示加载进度对话框。

private class AsyncLoadBuildingData extends AsyncTask<Void, Void, Void>{

    ProgressDialog mDialog = new ProgressDialog(thisClassName.this);

    @Override
    protected void onPreExecute(){      
        mDialog.setMessage("Please wait...");
        mDialog.show();
    }

    @Override
    protected Void doInBackground(Void... voids) {

        getBuildingData();
        return null;

    }

    @Override
    protected void onProgressUpdate(Void... progress) {
    }

    @Override
    protected void onPostExecute(Void voids){
        mDialog.dismiss();

   }

}

但是,使用此设置,阵列无法填充。

编辑:stacktrace

java.lang.UnsupportedOperationException
at org.eclipse.jdi.internal.MirrorImpl.defaultReplyErrorHandler(MirrorImpl.java:255)
at org.eclipse.jdi.internal.ReferenceTypeImpl.classObject(ReferenceTypeImpl.java:752)
at org.eclipse.jdt.internal.debug.core.model.JDIReferenceType.getClassObject(JDIReferenceType.java:109)
at org.eclipse.jdt.internal.debug.eval.ast.engine.AbstractRuntimeContext.classForName(AbstractRuntimeContext.java:117)
at org.eclipse.jdt.internal.debug.eval.ast.engine.AbstractRuntimeContext.classForName(AbstractRuntimeContext.java:150)
at org.eclipse.jdt.internal.debug.eval.ast.instructions.Instruction.getType(Instruction.java:204)
at org.eclipse.jdt.internal.debug.eval.ast.instructions.PushType.execute(PushType.java:29)
at org.eclipse.jdt.internal.debug.eval.ast.engine.Interpreter.execute(Interpreter.java:66)
at org.eclipse.jdt.internal.debug.eval.ast.engine.ASTEvaluationEngine$1$EvaluationRunnable.run(ASTEvaluationEngine.java:483)
at org.eclipse.jdt.internal.debug.core.model.JDIThread.runEvaluation(JDIThread.java:681)
at org.eclipse.jdt.internal.debug.eval.ast.engine.ASTEvaluationEngine$EvalRunnable.run(ASTEvaluationEngine.java:520)
at org.eclipse.jdt.internal.debug.core.model.JDIThread$ThreadJob.run(JDIThread.java:2756)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)

0 个答案:

没有答案