首页 > 其他 > 详细

MaterialRefreshLayout

时间:2016-11-06 01:54:28      阅读:369      评论:0      收藏:0      [点我收藏+]

技术分享

 

以上就介绍了比SwipeRefreshLayout更漂亮和强大的下拉刷新控件:Android-MaterialRefreshLayout

1.xml

<?xml version="1.0" encoding="utf-8"?>  
<LinearLayout  
    xmlns:android="http://schemas.android.com/apk/res/android"  
    android:orientation="vertical"  
    android:layout_width="match_parent"  
    android:layout_height="match_parent">  
  
    <com.cjj.MaterialRefreshLayout  
        xmlns:android="http://schemas.android.com/apk/res/android"  
        xmlns:app="http://schemas.android.com/apk/res-auto"  
        android:id="@+id/refresh"  
        app:wave_color="@color/material_green"  
        android:layout_width="match_parent"  
        android:layout_height="match_parent"  
        >  
  
     <ListView  
         android:background="#FF0000"  
         android:layout_width="match_parent"  
         android:layout_height="match_parent"></ListView>  
  
    </com.cjj.MaterialRefreshLayout>  

</LinearLayout> 

2.Java

package com.frame.activity;  
  
import android.app.Activity;  
import android.os.Bundle;  
import android.os.Handler;  
import android.widget.Toast;  
  
import com.cjj.MaterialRefreshLayout;  
import com.cjj.MaterialRefreshListener;  
import com.frame.R;  
   
public class TestActivity extends Activity {  
  
    MaterialRefreshLayout materialRefreshLayout ;  
  
    @Override  
    protected void onCreate(Bundle savedInstanceState) {  
        super.onCreate(savedInstanceState);  
        setContentView(R.layout.test_activity_test);  
  
        materialRefreshLayout = (MaterialRefreshLayout) findViewById(R.id.refresh);  
        //支持上拉加载更多  
        materialRefreshLayout.setLoadMore(true);  
        materialRefreshLayout.setMaterialRefreshListener(new MaterialRefreshListener() {  
            @Override  
            public void onRefresh(final MaterialRefreshLayout materialRefreshLayout) {  
               new Handler().postDelayed(new Runnable() {  
                   @Override  
                   public void run() {  
                       //下拉刷新更多  
                       Toast.makeText(TestActivity.this,"onRefresh...",Toast.LENGTH_LONG).show();  
                       materialRefreshLayout.finishRefresh();  
                   }  
               }, 3000);  
            }  
  
            @Override  
            public void onRefreshLoadMore(final MaterialRefreshLayout materialRefreshLayout) {  
                new Handler().postDelayed(new Runnable() {  
                    @Override  
                    public void run() {  
                        //上拉加载更多  
                        Toast.makeText(TestActivity.this,"onRefreshLoadMore...",Toast.LENGTH_LONG).show();  
                        materialRefreshLayout.finishRefreshLoadMore();  
                    }  
                }, 3000);  
            }  
        });  
    }  
}  

  

3、参考网站

https://github.com/android-cjj/Android-MaterialRefreshLayout/blob/master/README-cn.md

MaterialRefreshLayout

原文:http://www.cnblogs.com/ganchuanpu/p/6034338.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!