进度对话框不适用于自定义列表适配器

发布于 2024-11-17 06:20:50 字数 664 浏览 0 评论 0原文

使用 listAdapter 列出数据时进度对话框不起作用

我认为这都是关于将活动发送到 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();

progress dialog doesnt 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();

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

盗琴音 2024-11-24 06:20:50

这里有一些关于线程的信息,如果我是你,我会使用 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();
    }
}

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();
    }
}
陪我终i 2024-11-24 06:20:50

使用 dialog.show(); 显示对话框。您使用 dialog.dismiss(); 直接关闭对话框;

use dialog.show(); to show dialog. you are directly dismissing the dialog using dialog.dismiss();

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文