我希望在调用ProgressDialog
时启动onPreExecute()
,但它无效。
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....
}
}
答案 0 :(得分:7)
将onPreExecute
方法更改为:
@Override
protected void onPreExecute()
{
progresdialoglistview=ProgressDialog.show(HomeActivity.this, "","Loading");
Log.e("onPreExecutive","called"+progresdialoglistview);
}
onPreExecute()方法不接受任何参数并且具有void返回类型。所以也从onPreExecute
中删除return答案 1 :(得分:4)
您没有覆盖 onPreExecute
,而是重载。
onPreExecute
不接受任何参数并且不返回任何内容。请改用:
protected void onPreExecute()