不能覆盖onPostExecute()方法中的AsyncTask类或得到它的触发 [英] Can't Override onPostExecute() method in AsyncTask Class or get it to trigger

查看:288
本文介绍了不能覆盖onPostExecute()方法中的AsyncTask类或得到它的触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法运行时,一个的AsyncTask 获得 onPostExecute()方法来调用。当我尝试建立我的延长的AsyncTask 类,其中 onPostExecute()被重写,我得到了下面的生成错误

  

的方法onPostExecute类型AsyncTaskExampleActivity的()必须   覆盖或实现超类型的方法

我试图摆脱 @覆盖注释。这摆脱了生成错误的,但该方法仍不能执行。如果任何一个人会这么好心地指出什么我俯瞰,我将不胜AP preciated吧。

code:

 包com.asynctaskexample;

进口android.os.AsyncTask;

公共类AsyncTaskExampleActivity扩展的AsyncTask<虚空,虚空,虚空> {

AsyncTaskExampleActivity(){
超();
    }

@覆盖
在preExecute保护无效(){
    }

@覆盖
保护无效doInBackground(虚空...... PARAMS){
    返回null;
}

@覆盖
保护无效onPostExecute(){
    }
}
 

解决方案

<一个href="http://developer.android.com/reference/android/os/AsyncTask.html#onPostExecute%28Result%29"><$c$c>OnPostExecute()带有参数的(从返回对象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.

'The method onPostExecute() of type AsyncTaskExampleActivity must override or implement a supertype method'

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类或得到它的触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆