[Kaizige takes you to consolidate the application layer] Is XListView still in use? Try the more beautiful AutoLoadListView !, Xlistview

Source: Internet
Author: User
Tags autoload

[Kaizige takes you to consolidate the application layer] Is XListView still in use? Try the more beautiful AutoLoadListView !, Xlistview

Reprinted please indicate the source: http://blog.csdn.net/zhaokaiqiang1992

There are already many solutions for pull-up refresh and pull-down loading. XListView and PullToRefresh are well-known open-source projects, which can solve our needs. However, today we use a simpler method to implement the pull-up refresh and pull-down loading functions. I call it AutoLoadListView ~

First.

The refresh effect is implemented using the SwipeRefreshLayout of the v4 compatibility package after version 19. The effect is pretty good. The JumpingBeans of another open-source project is used to automatically load the next page, is it awesome to beat the ellipsis?

The following describes how to use it.

  • Layout File
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"    xmlns:tools="http://schemas.android.com/tools"    android:layout_width="match_parent"    android:layout_height="match_parent" >    <android.support.v4.widget.SwipeRefreshLayout        android:id="@+id/swipe_refresh"        android:layout_width="match_parent"        android:layout_height="match_parent" >        <com.socks.autoload.AutoLoadListView            android:id="@+id/listview"            android:layout_width="match_parent"            android:layout_height="match_parent" >        </com.socks.autoload.AutoLoadListView>    </android.support.v4.widget.SwipeRefreshLayout></RelativeLayout>
  • Refresh. We need to implement the SwipeRefreshLayout. OnRefreshListener interface for refreshing, and then implement the refresh logic in onRefresh ().
public void onRefresh()
  • Load the next page. We need to add an interface and implement our loading task in the callback.
listView.setOnLoadNextListener(new OnLoadNextListener() {            @Override            public void onLoadNext() {                handler.sendEmptyMessageDelayed(MSG_LOAD_MORE, 3000);            }        });

Is it easy to use?

Some may ask, what should I do if I want to slide and delete it?
Else...
This is not the only interaction effect! Why can't we hold on to this effect! You can use the [] described earlier to use ActionMode to delete multiple choices of animations !!!
Well, since your product manager is addicted to this effect, let's do it...

  • Step 1: Find Our ZListView. If you do not know the truth, please stamp [Android interface implementation] ZListView, the most powerful ListView Control for refreshing, loading, and sliding deletion (1)
  • Copy all classes except ZlistView to our project.
  • Replace ZListView with AutoLoadListView.

Check it out. OK, too ~ However, because it is a demo, many businesses are not processed. This requires you to modify the source code based on your needs. Isn't the benefits of open-source projects here ~

Github Project address of AutoLoadListView

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.