【发布时间】:2014-07-07 01:49:51
【问题描述】:
在尝试通过@Slartibartfast 的回答暗示How to show ProgressDialog across launching a new Activity? 时,我试图让它在我的编辑器中工作但没有成功。在这里,我试图在程序获取一些联系人信息时显示一个响铃 progressDialog。然后,稍后,在 OnCreate 中,它把它放在 ListView 中。我的问题是没有progressDialog 出现过。我的代码如下:
声明
private ProgressDialog ringProgressDialog = null;
AsyncTask - 启动并结束环形progressDialog
private class load_contact_list extends AsyncTask<String, Void, Integer> {
@Override
protected Integer doInBackground(String... url) {
...
}
@Override
protected void onPostExecute(Integer list_length) {
ringProgressDialog.dismiss();
setContentView(R.layout.activity_main);
}
}
创建时
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ringProgressDialog = ProgressDialog.show(MainActivity.this, "Loading contacts", "Please Wait", true);
new load_contact_list().execute(...);
}
...
我尽最大努力使我的代码与他的代码相似,但我不知道为什么它不起作用。提前致谢。
编辑: doInBackground() 中的省略号集是获取联系信息的位置。另一组,在 OnCreate 中,是将信息放入列表的位置。
【问题讨论】:
标签: android android-asynctask progressdialog