Giter Site home page Giter Site logo

wherego / easystatusview Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lili-z/easystatusview

0.0 1.0 0.0 379 KB

多种状态切换视图,包括加载中,加载错误,空数据,网络错误重试页面,使用灵活,支持在xml或代码中指定对应布局

Java 100.00%

easystatusview's Introduction

#RapidLibs

####一、简介: 一个多状态视图切换的控件,继承自RelativeLayout可以直接作为最外层布局使用,支持在布局中或代码中指定不同状态下的布局

1.1 Gradle集成

allprojects {
    repositories {
        ...
        maven { url "https://jitpack.io" }
    }
}
dependencies {
     compile 'com.github.MarnonDev:EasyStatusView:v1.0.3'
}

####二、截图预览

####三、使用方法 3.1 属性列表

属性名称 说明
esv_loading 指定加载中布局
esv_empty 指定空视图
esv_error 指定错误视图
esv_noNet 指定无网络视图

3.2 提供方法

方法名 作用
empty() 显示空视图
error() 显示加载错误
loading() 显示加载中
noNet() 显示无网络连接
content() 显示内容
setEmptyView() 设置空布局
setErrorView() 设置加载错误布局
setLoadingView() 设置加载中布局
setNoNetworkView() 设置无网络布局
setEmptyLayoutId() 设置空布局资源id
setErrorLayoutId() 设置错误布局资源id
setLoadingLayoutId() 设置加载中布局资源id
setNoNetworkLayoutId() 设置无网络布局资源id
getEmptyView() 获取空布局
getErrorView() 获取错误布局
getLoadingView() 获取加载中布局
getNoNetworkView() 获取无网络布局
getCurrentStatus() 获取当前显示状态

3.3 示例代码

在布局资源文件中中指定对应视图布局资源id

<com.marno.easystatelibrary.EasyStatusView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/esvlayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:esv_empty="@layout/layout_empty"
    app:esv_error="@layout/layout_error"
    app:esv_loading="@layout/layout_loading"
    app:esv_noNet="@layout/layout_no_net">

    <ListView
        tools:listitem="@layout/item_main"
        android:id="@+id/lv_content"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

</com.marno.easystatelibrary.EasyStatusView>
EasyStatusView mEsvLayout = (EasyStatusView) findViewById(R.id.esvlayout);
mEsvLayout.empty();//显示空视图
mEsvLayout.error();//显示错误视图
mEsvLayout.loading();//显示加载中视图
mEsvLayout.noNet();//显示无网络视图
mEsvLayout.content();//显示内容

或者在代码中设定对应状态布局资源id

<com.marno.easystatelibrary.EasyStatusView
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/esvlayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <ListView
        tools:listitem="@layout/item_main"
        android:id="@+id/lv_content"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>

</com.marno.easystatelibrary.EasyStatusView>
EasyStatusView mEsvLayout = (EasyStatusView) findViewById(R.id.esvlayout);
        
//没有在布局属性中指定对应状态的布局时,需要在代码中先指定好才能使用
mEsvLayout.setEmptyLayoutId(R.layout.layout_empty);
mEsvLayout.setErrorLayoutId(R.layout.layout_error);
mEsvLayout.setLoadingLayoutId(R.layout.layout_loading);
mEsvLayout.setNoNetworkLayoutId(R.layout.layout_no_net);

mEsvLayout.empty();//显示空视图
mEsvLayout.error();//显示错误视图
mEsvLayout.loading();//显示加载中视图
mEsvLayout.noNet();//显示无网络视图
mEsvLayout.content();//显示内容

####四、关于我 Marno

easystatusview's People

Watchers

 avatar

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.