Giter Site home page Giter Site logo

androidrefreshlayout's Introduction

AndroidRefreshLayout

Android万能刷新加载框架,适用于所有View,可根据自己需求定制!
本Demo演示如何使用通用的下拉刷新上拉加载控件,demo中已经实现了常见的需要上下拉功能的控件,其他控件如果需要加入这两个功能可自行扩展,实现Pullable接口即可

应用截图

使用方法

具体使用方法以ListView为例,用法基本上都一样,很简单!

布局文件声明

<com.chenzhi.refresh.PullToRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/refresh_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <include layout="@layout/refresh_head" />
    <!-- 支持所有实现Pullable接口的View -->

    <com.chenzhi.refresh.PullableListView
        android:id="@+id/list_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

    </com.chenzhi.refresh.PullableListView>

    <include layout="@layout/load_more" />

</com.chenzhi.refresh.PullToRefreshLayout>

代码使用

查找刷新控件
mRefreshView = findViewById(R.id.refresh_view); 
设置监听
 mRefreshView.setOnRefreshListener(this);
实现接口
public class ListViewActivity extends AppCompatActivity implements PullToRefreshLayout.OnRefreshListener{
覆写回调方法
@Override
public void onRefresh(final PullToRefreshLayout pullToRefreshLayout) {
    handler.postDelayed(new Runnable() {
        @Override
        public void run() {
            pullToRefreshLayout.refreshFinish(PullToRefreshLayout.SUCCEED);
            Toast.makeText(ListViewActivity.this, "刷新结束", Toast.LENGTH_SHORT).show();
        }
    },1000);
}

@Override
public void onLoadMore(final PullToRefreshLayout pullToRefreshLayout) {
    handler.postDelayed(new Runnable() {
        @Override
        public void run() {
            pullToRefreshLayout.loadmoreFinish(PullToRefreshLayout.SUCCEED);
            Toast.makeText(ListViewActivity.this, "加载完成", Toast.LENGTH_SHORT).show();
        }
    },1000);
}

androidrefreshlayout's People

Contributors

westlifechen avatar

Stargazers

cheny avatar  avatar  avatar  avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.