progress dialog doesnt work with custom list adapter
progress dialog d开发者_如何转开发oesnt work while listing data with listAdapter
i think its all about sending activity to 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();
here's some information on threading, i would use an AsyncTask if I were you:
http://developer.android.com/resources/articles/painless-threading.html
Something similar to this should work:
LoadListTask tsk = new LoadListTask();
tsk.execute((Void) null);
with this somewhere
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();
}
}
use dialog.show();
to show dialog. you are directly dismissing the dialog using dialog.dismiss();
精彩评论