一个可以用来切换多种状态视图的view,适用于加载失败状态、空数据状态、网络异常状态等场景,同时支持自定义视图!
- 使用Gradle
// 注:如果添加依赖成功,则此句不必添加,此句作用仅为当项目在被审核时,紧急需要使用时添加
allprojects {
repositories {
...
// 如果添加依赖时,报找不到项目时(项目正在审核),可以添加此句maven地址,如果找到项目,可不必添加
maven { url "https://dl.bintray.com/albertlii/android-maven/" }
}
}
dependencies {
compile 'com.liyi.view:multiple-status-view:1.0.1'
}
- 使用Maven
<dependency>
<groupId>com.liyi.view</groupId>
<artifactId>multiple-status-view</artifactId>
<version>1.0.1</version>
<type>pom</type>
</dependency>
类型 | 说明 |
---|---|
MultipleStatusView.ViewType.TYPE_LOADING | 加载中 |
MultipleStatusView.ViewType.TYPE_NETWORK_POOR | 网络异常 |
MultipleStatusView.ViewType.TYPE_EMPTY | 空数据 |
MultipleStatusView.ViewType.TYPE_ERROR | 加载失败 |
MultipleStatusView.ViewType.TYPE_SPECIFIED | 自定义 |
**除了默认提供的类型,也可自定义类型
属性 | 说明 |
---|---|
loading | 加载中视图 |
network_poor | 网络异常视图 |
empty | 空数据视图 |
error | 加载失败视图 |
specified | 自定义视图 |
// 显示指定类型的视图
MultipleStatusView.showView(int viewType)
// 动态设置视图
MultipleStatusView.setView(int viewType,int layoutId)
MultipleStatusView.setView(int viewType,View view)
// 关闭状态视图
MultipleStatusView.dismiss()
<com.liyi.multiple.MultipleStatusView
android:id="@+id/multipleStatusView_custom"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:empty="@layout/custom_test_view"
app:error="@layout/custom_test_view"
app:loading="@layout/custom_test_view"
app:network_poor="@layout/custom_test_view"
app:specified="@layout/custom_test_view" />
如果你感觉 MultipleStatusView
帮助到了你,可以点右上角 "Star" 支持一下哦!:blush:
Copyright 2017 liyi
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.