| 注册
请输入搜索内容

热门搜索

Java Linux MySQL PHP JavaScript Hibernate jQuery Nginx
jopen
10年前发布

设置ListView加载中,空数据,加载数据失败三种状态的显示

设置listview加载中,空数据,加载数据失败三种状态的显示。

A library for showing different types of layouts when a list view is empty. These layouts can be shown when,

  • the list is loading
  • the list has no item to display
  • an error occured trying to load items

Loading animation is also supported.

Screenshots

设置ListView加载中,空数据,加载数据失败三种状态的显示设置ListView加载中,空数据,加载数据失败三种状态的显示设置ListView加载中,空数据,加载数据失败三种状态的显示设置ListView加载中,空数据,加载数据失败三种状态的显示

Usage

  1. Import the library project into your workspace.
  2. Use the imported project as a library for your project.
  3. In the onCreate event of your activity use the following code.

    mListAdapter.clear(); EmptyLayout emptyLayout = new EmptyLayout(this, getListView()); 
  4. When you want to show the loading animation, use this code.

    mListAdapter.clear(); emptyLayout.showLoading(); 
  5. When you want to show any error, use this code.

    mListAdapter.clear(); emptyLayout.showError(); 
  6. When your list doesn't have any item to show, use this code.

    mListAdapter.clear(); emptyLayout.showEmpty(); 

    Thats all you have to do to use this library. You may want to customize its behavior though.

P.S. Make sure you always clear the list adapter before calling showEmpty, showLoading and showError. The list have to empty after all.

Customization

There are bunch of methods to let you customize this pattern. Use the methods like this.

emptyLayout.setLoadingMessage("Please wait..."); 

Some useful methods are given below

  • showEmpty
  • showLoading
  • showError
  • setLoadingView
  • setEmptyView
  • setErrorView
  • setLoadingAnimation
  • setErrorMessage
  • setLoadingMessage
  • setEmptyMessage
  • setEmptyViewButtonClickListener
  • setLoadingViewButtonClickListener
  • setErrorViewButtonClickListener
  • setShowEmptyButton
  • setShowLoadingButton
  • setShowErrorButton

and there is more...

项目主页:http://www.open-open.com/lib/view/home/1409300611932

 本文由用户 jopen 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
 转载本站原创文章,请注明出处,并保留原始链接、图片水印。
 本站是一个以用户分享为主的开源技术平台,欢迎各类分享!
 本文地址:https://www.open-open.com/lib/view/open1409300611932.html
ListView Android开发 移动开发