自定义ProgressStateLayout实现网络请求状态间的相互切换

http://www.jianshu.com/p/66436928d99b

http://blog.csdn.net/zengyunshu/article/details/52262526

数据载入状态布局集成allprojects {     repositories {         maven { url "https://jitpack.io" }     } }dependencies {     compile 'com.github.nguyenhoanglam:ProgressLayout:1.0.1' }使用像使用RelativeLayout一样(其实ProgressLayout继承了RelativeLayout):<?xml version="1.0" encoding="utf-8"?> <com.nguyenhoanglam.progresslayout.ProgressLayout xmlns:android="http://schemas.android.com/apk/res/android"     xmlns:app="http://schemas.android.com/apk/res-auto"     android:id="@ id/progressLayout"     android:layout_width="match_parent"     android:layout_height="match_parent">     <android.support.v7.widget.Toolbar         android:id="@ id/toolbar"         android:layout_width="match_parent"         android:layout_height="?attr/actionBarSize"         android:layout_alignParentTop="true"         android:background="@color/colorPrimary"         app:theme="@style/CustomToolbarTheme" />     <TextView         android:layout_width="match_parent"         android:layout_height="match_parent"         android:layout_below="@id/toolbar"         android:layout_centerInParent="true"         android:gravity="center"         android:text="YOUR CONTENT HERE"         android:textSize="24sp" /> </com.nguyenhoanglam.progresslayout.ProgressLayout>切换状态progressLayout.showLoading();//???? progressLayout.showEmpty();//???? progressLayout.showError();//????设置监听List<Integer> skipIds = new ArrayList<>(); skipIds.add(R.id.toolbar);         progressLayout.showLoading(skipIds);         progressLayout.showEmpty(ContextCompat.getDrawable(this, R.drawable.ic_empty), "Empty data",skipIds); //        progressLayout.showError(ContextCompat.getDrawable(this, R.drawable.ic_no_connection), "No connection", "RETRY", new View.OnClickListener() { //            @Override //            public void onClick(View view) { //                Toast.makeText(MainActivity.this, "Reloading...", Toast.LENGTH_SHORT).show(); //            } //        },skipIds);           // Show progress layout, hide all main views //        progressLayout.showLoading(); //        progressLayout.showEmpty(ContextCompat.getDrawable(this, R.drawable.ic_empty), "Empty data"); //        progressLayout.showError(ContextCompat.getDrawable(this, R.drawable.ic_no_connection), "No connection", "RETRY", new View.OnClickListener() { //            @Override //            public void onClick(View view) { //                Toast.makeText(MainActivity.this, "Reloading...", Toast.LENGTH_SHORT).show(); //            } //        });skipIds是ProgressLayout中显示的view id列表 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值