gpt4 book ai didi

未调用 PreExecute 方法上的 Android Asynctask

转载 作者:行者123 更新时间:2023-11-29 14:20:51 24 4
gpt4 key购买 nike

我想在调用 onPreExecute() 时启动一个 ProgressDialog,但它不起作用。

Homeactivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

//switch condtion...
case R.id.buttontime :
new FlightListTask().execute("");
break:

}

public class FlightListTask extends AsyncTask<String,ArrayList<HashMap<String, String>>, ArrayList<HashMap<String, String>>> {

protected String onPreExecute(String temp) {
progresdialoglistview=ProgressDialog.show(HomeActivity.this, "", "Loading");
Log.e("onPreExecutive","called"+progresdialoglistview);
return temp;
}

@Override
protected ArrayList<HashMap<String, String>> doInBackground( String... params ) {
return flightlist;
}

protected void onPostExecute(ArrayList<HashMap<String, String>> flightList) {
// listview code....
}

}

最佳答案

将您的onPreExecute 方法更改为:

  @Override
protected void onPreExecute()
{
progresdialoglistview=ProgressDialog.show(HomeActivity.this, "","Loading");
Log.e("onPreExecutive","called"+progresdialoglistview);

}

onPreExecute()方法不接受任何参数并具有 void 返回类型。所以也从 onPreExecute 中删除 return

关于未调用 PreExecute 方法上的 Android Asynctask,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13800011/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com