android 空页面 错误页面,StatusView空页面|错误页面|加载中页面处理

StatusView

Android 空页面|错误页面|加载中页面处理,支持所有的布局,使用简单方便

ba512e4d7458

网络错误情况

ba512e4d7458

加载中情况

ba512e4d7458

数据为空情况

ba512e4d7458

正常显示内容

ba512e4d7458

去设置网络

使用步骤

1.根据实际需求实现StatusView

继承StatusView基类,实现各个页面的初始化,这样做的好处是我么你可以根据不同的需求,创建不同的加载页面或者其他页面的样式。也可以根据实际开发需求对各个页面进行不同的出来,比如,加载页面加载样式的不同,数据为空的页面,根据不同的调用模块 ,显示不同的内容。 可以只需要创建一次,全局使用。

ba512e4d7458

Paste_Image.png

2.创建StatusLayout对象

方法一:强烈推荐,直接在代码中使用就可以。

StatusLayout statusLayout;

statusLayout =new StatusLayout.Builder()

.setContentView(contentView)//设置正常显示内容的VIEW

.setStatusView(statusView)

.build();

方式二:首先在XML布局中使用,然后再activity里像正常的空间

android:id="@+id/status_layout"

android:layout_width="match_parent"

android:layout_height="match_parent">

android:layout_width="match_parent"

android:layout_height="match_parent"

android:background="#ef5464">

android:layout_width="match_parent"

android:layout_height="match_parent"

android:text="正常文本内容" />

StatusLayout statusLayout;

statusLayout = (StatusLayout) findViewById(R.id.status_layout);

statusLayout.setStatusView(statusView);//设置statisView

3.使用StatusLayout

statusLayout.showLoading();

statusLayout.showEmpty();

statusLayout.showContent();

statusLayout.showRetry();

statusLayout.showSetting();

用起来很方便吧,一些比较常用的VIEW ,DEMO里写了一个MyStatusView.

暂时大家只能把library下面的文件拷贝出来使用,等弄好jcenter,就可以直接引用使用了

ba512e4d7458

status

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值