如何显示"载入中..."文本在检索了一个ListView项目 [英] How to display a "Loading..." text while retrieving items for a ListView

查看:132
本文介绍了如何显示"载入中..."文本在检索了一个ListView项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一些其他的应用程序做这个,像Twitter,Facebook的,甚至本机应用程序,例如Android Market的。当你想显示从互联网上检索到的项目清单,这看起来像一个标准的方式来显示用户关于正在操作一些通知。这是一个动画纺车和一个载入中...文本在白色背景画面。是否有人知道如何做到这一点?我已经能够做这个code类似的东西,但我不喜欢太多呢。工作仍然在进行中:

 < ListView的机器人:ID =@ + ID / post_list
            机器人:layout_width =FILL_PARENT
   机器人:layout_height =WRAP_CONTENT/>
    < TextView的机器人:ID =@机器人:ID /加载机器人:背景=@色/白
   机器人:layout_width =FILL_PARENT
            机器人:layout_height =FILL_PARENT
   机器人:重力=中心的android:文本=正在加载.../>
 

解决方案

当用户滚动到下您的适配器的getView应该返回一个视图中..文字和纺纱进度。与此同时AsyncTask的或后台线程应启动的下载内容的新块。当内容已准备就绪adapter.notifyDatasetChanged()被调用和ListView重新显示,包括新项目的所有内容。

所以,正在加载...消息在ListView只是最后一个项目。

There are some others applications doing this, like Twitter, Facebook, or even native applications such as Android Market. When you want to display a list of items retrieved from the internet, this looks like a standard way for displaying the user some notification about action in progress. This is a white background screen with an animated spinning wheel and a "Loading..." text. Does somebody know how to do this?. I've been able to do something similar with this code, but i don't like it too much yet. Still work in progress:

    <ListView android:id="@+id/post_list" 
            android:layout_width="fill_parent"
   android:layout_height="wrap_content"/>
    <TextView android:id="@android:id/loading" android:background="@color/white"
   android:layout_width="fill_parent"     
            android:layout_height="fill_parent" 
   android:gravity="center" android:text="Loading..." />

解决方案

When user scrolls to the bottom your adapter's getView should return a view with "Loading.." text and spinning progress. At the same time AsyncTask or background thread should be started that downloads a new chunk of content. When content is ready adapter.notifyDatasetChanged() is called and ListView redisplays all content including the new items.

So "Loading..." message is just a last item in the ListView.

这篇关于如何显示&QUOT;载入中...&QUOT;文本在检索了一个ListView项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆