Android github XListView analysis (2-3), githubxlistview

Source: Internet
Author: User

Android github XListView analysis (2-3), githubxlistview
Content

  • Overview
  • XListView UML diagram
Download github XListView Overview

We often see the "pull more" and "pull up and load" Effects of listview in the app. As shown in the following figure:

Figure 1 Common headers and Footer

(Left: three States on the top; Right: three States on the bottom)

Obviously, there are three statuses at the top and bottom of the drop-down list or top-up list. For example,

  • For the "drop-down" operation, if you click "drop-down", the system will prompt "pull-down Update". If you continue the pull-down operation and do not release the operation, the system will change to "Release and refresh". The arrow will change during this period. Once released, "loading" is displayed ".
  • For the "pull up" operation, the pull up operation is similar, but the prompt is slightly different. When sliding the listview to the bottom, you can see "View"

Therefore, there are six statuses at the top and bottom of the listview: "pull-down refresh", "Release refresh data", and "loading... "," Last Update time: "," view more ", and" Release and load more ".

You can change the top and bottom statuses when pulling the listview. In this way, you must define at least three classes: Custom listview, header, and footer.

In addition, if listview needs to know the user's pull height, it will reserve a height in advance. For example, if it is only "drop-down", the system will prompt "pull-down refresh". If it exceeds the pre-height, the system prompts "Release and refresh". At this time, you need to change the direction of the arrow.

To enable your Activity or Fragment to use the encapsulated listview, you also need to define an interface. In this way, the encapsulated listview can be used as long as this interface is inherited.

XListView UML diagram

Figure 2 XListView UML diagram

  • CustomXListViewClass, which inheritsAndroid. widget. AbsListView. OnScrollListenerAndAndroid. widget. ListView;
  • Top of the custom listviewXListViewHeaderAnd bottomXListViewFooter, They all inheritAndroid. widget. LinearLayout;
  • Custom XListView InterfaceIXListViewListenterThere are only two methods:OnRefreshAndOnLoadMoreThis interface is very important. In the future, if you use any Activity or Fragment of the XListView control to inherit this interface and implement the two methods, the "pull-down Update" and "pull-up loading" functions of listview can be implemented. That is to say, if you pull down, it will call your Activity and FragmentOverride OnRefreshMethod.OverrideOnLoadMoreMethod;
  • Obviously, the XListView class needs to be combinedXListViewHeader,XListViewFooterAndIXListViewListenter.
 

After reading the structure, you can look at the public method to get a rough idea of the control.

 

Android: Android ListView and github XListView (1-3)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.