Android GitHub Xlistview Analysis (2-3)

Source: Internet
Author: User

Content of this article
    • Overview
    • Xlistview UML diagram
Download GitHub Xlistview Overview

We often see the effects of "pull more" and "pull-up" in the ListView in the app. As shown in the top and bottom changes:

Fig. 1 Common headers and Footer

(left: three states at the top, right: three states at the bottom)

It is clear that both the top and the bottom are three states, either pull-down or pull-up. Such as

    • For the "pull down" operation, "drop down" point, will prompt "drop-down update", if continue to pull down, do not release, will become "release refresh", the period arrows will change, once released, it shows "loading."
    • For the pull-up operation, the pull-up is similar, but the hint is slightly different. When sliding the ListView to the bottom, see "View"

Therefore, the top and bottom of the ListView need six states altogether: "Drop-down Refresh", "Release Refresh Data", "Loading ...", "Last Updated:", "View More", "Release load More".

You need to change the top and bottom states separately when pulling the ListView. At a minimum, you need to customize three classes: Custom ListView, Header, and footer.

And the ListView to be able to know the user pull the height is how much, beforehand will be predetermined a height, for example, if only "pull down" point, then the prompt "drop refresh", if the predetermined height, the prompt "release refresh", at this time, to change the direction of the arrow.

In order for your Activity or Fragment to use the encapsulated ListView, you also need to define an interface. This allows the encapsulated ListView to be used as long as the interface is inherited.

Xlistview UML diagram

Figure 2 Xlistview UML diagram

    • Custom Xlistview class, which inherits Android.widget.AbsListView.OnScrollListener and Android.widget.ListView ;
    • Customize the top of the ListView xlistviewheader and bottom xlistviewfooter, they all inherit android.widget.LinearLayout;
    • Custom Xlistview Interface Ixlistviewlistenter, only two methods:Onrefresh and onloadmore, this interface is important, later you use Any Activity and Fragment of the Xlistview control can implement the drop-down update and pull-up loading functions of the ListView as long as the interface is inherited and two of these methods are implemented. That is, if you pull down, you call the override Onrefresh method of your Activity and Fragment, and when you pull up, the override Onloadmore method;
    • Obviously, the Xlistview class needs to combine xlistviewheader,xlistviewfooter , and ixlistviewlistenter.

Look at the structure, then look at the public method, you can probably understand the idea of the control.

Android demo Android ListView and GitHub Xlistview (1-3)

Android GitHub Xlistview Analysis (2-3)

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.