Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/192.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 调用AsyncTask的方法时出现问题_Android_Asynchronous_Android Asynctask - Fatal编程技术网

Android 调用AsyncTask的方法时出现问题

Android 调用AsyncTask的方法时出现问题,android,asynchronous,android-asynctask,Android,Asynchronous,Android Asynctask,我正在尝试使用AsyncTask更新进度条 我的代码如下所示 private class ProgressBar extends AsyncTask<Void, Integer, Integer> { protected Integer doInBackground(Void... params) { int a=2; for(int i=0;i<=100;i=i+5) { SystemClock.sleep(1000);

我正在尝试使用AsyncTask更新进度条 我的代码如下所示

private class ProgressBar extends AsyncTask<Void, Integer, Integer>
{
 protected Integer doInBackground(Void... params) 
 {
    int a=2;
    for(int i=0;i<=100;i=i+5)
    {
        SystemClock.sleep(1000);
        publishProgress(i);
    }
    return a;
 }

 protected void onProgressUpdate(Integer... item) 
 {
    //int no_of_argruments=item.length;
    tv.setText("Over !!"+item[0]);
    bar.setProgress(item[0]);
 }

protected void onPostExecute()
{
    if(result[0]!=null)
    {
        tv.setText("Hurray !!");
        Toast.makeText(checkThread.this, "Done!", Toast.LENGTH_SHORT)
        .show();
    }
}
私有类ProgressBar扩展异步任务
{
受保护的整数doInBackground(Void…params)
{
INTA=2;

对于(int i=0;i这是postExecute()的正确签名

您的方法是您自己的方法,
AsyncTask
对此一无所知

protected void onPostExecute (Result result)