问题描述
我无法运行时,一个的AsyncTask
获得 onPostExecute()
方法来调用。当我尝试建立我的延长的AsyncTask
类,其中 onPostExecute()
被重写,我得到了下面的生成错误
我试图摆脱 @覆盖
注释。这摆脱了生成错误的,但该方法仍不能执行。如果任何一个人会这么好心地指出什么我俯瞰,我将不胜AP preciated吧。
code:
包com.asynctaskexample;
进口android.os.AsyncTask;
公共类AsyncTaskExampleActivity扩展的AsyncTask<虚空,虚空,虚空> {
AsyncTaskExampleActivity(){
超();
}
@覆盖
在preExecute保护无效(){
}
@覆盖
保护无效doInBackground(虚空...... PARAMS){
返回null;
}
@覆盖
保护无效onPostExecute(){
}
}
<$c$c>OnPostExecute()$c$c>带有参数的(从返回对象doInBackground()
)的。将其更改为保护无效onPostExecute(虚空V)
。如果不提供参数,该方法签名不匹配,并且覆盖注释开始抱怨没有功能重写与此签名。
I am having trouble getting the onPostExecute()
method to call when running an AsyncTask
. When I try to set up my class extending AsyncTask
in which the onPostExecute()
is overridden I get the following build error.
I have tried getting rid of the @Override
annotation. This gets rid of the build error but the method still does not execute. If any one would be so kind as to point out what I'm overlooking I would greatly appreciated it.
Code:
package com.asynctaskexample;
import android.os.AsyncTask;
public class AsyncTaskExampleActivity extends AsyncTask<Void, Void, Void> {
AsyncTaskExampleActivity(){
super();
}
@Override
protected void onPreExecute() {
}
@Override
protected Void doInBackground(Void... params) {
return null;
}
@Override
protected void onPostExecute() {
}
}
OnPostExecute()
takes an argument (the object you return from doInBackground()
). Change it to protected void onPostExecute(Void v)
. If you don't provide the argument, the method signatures do not match and the override annotation starts to complain that there is no function to override with this signature.
这篇关于不能覆盖onPostExecute()方法中的AsyncTask类或得到它的触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!