进度对话框不起作用
我认为所有关于向myAdapter发送活动
final myAdapter adapter = new myAdapter(rss_list_activity.this, liste);
final ProgressDialog dialog = ProgressDialog.show(this, "Title",
"Message", true);
final Handler handler = new Handler() {
public void handleMessage(Message msg) {
dialog.dismiss();
}
};
Thread checkUpdate = new Thread() {
public void run() {
getListFromXml();
lv.setAdapter(adapter);
handler.sendEmptyMessage(0);
}
};
checkUpdate.start();
答案 0 :(得分:1)
这里有一些关于线程的信息,如果我是你,我会使用AsyncTask:
http://developer.android.com/resources/articles/painless-threading.html
类似的东西应该有效:
LoadListTask tsk = new LoadListTask();
tsk.execute((Void) null);
有了这个
private class LoadListTask extends AsyncTask<Void, Void, List<theType>>
{
final ProgressDialog dialog;
@Override
protected void onPreExecute()
{
super.onPreExecute();
dialog = ProgressDialog.show(MainClass.this, "Title", "Message", true);
}
@Override
protected void onPostExecute(List<theType> result)
{
super.onPostExecute(result);
final myAdapter adapter = new myAdapter(rss_list_activity.this, result);
lv.setAdapter(adapter);
dialog.dismiss();
}
@Override
protected List<theType> doInBackground(Void... params)
{
return getListFromXml();
}
}
答案 1 :(得分:0)
使用dialog.show();
显示对话框。您正在使用dialog.dismiss();