Git Product home page Git Product logo

multiplestatusview's Introduction

MultipleStatusView

releasesvg apisvg license  

关于

一个可以用来切换多种状态视图的view,适用于加载失败状态、空数据状态、网络异常状态等场景,同时支持自定义视图!

演示

demogif

添加依赖

  • 使用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 viewTypeView view)
  
  // 关闭状态视图
  MultipleStatusView.dismiss()

xml中使用

  <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:

LICENSE

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.

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.