Giter Site home page Giter Site logo

cuishijie1991 / loadinglayout Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 1.0 249 KB

a simple frameLayout which handles loading, having result, having no result, having error result states. 一个封装了加载页,结果页,无结果页,错误页切换的FrameLayout,

Java 100.00%

loadinglayout's Introduction

LoadingLayout


一个简单轻量的FrameLayout布局,封装了开发中常用的加载页面、结果页面、无结果页面、错误页面的切换。 允许设置工程的默认页面布局,也可以自定义设置对应页面布局。免去了在项目开发中不断要Copy各种默认状态页面并要进行显示隐藏的麻烦,欢迎使用~
A smiple and lightweight frameLayout which handles the switching between LoadingLayout、 resultLayout、noResultLayout and errorLayout in your project. It is easy to define your default or custom layouts and will really reduce much pain from boring copy codes.Welcome to use

##效果图

effect gif

##用法

  • Copy LoadingLayout.java 并添加到自己到工程。在变量定义的地方可以添加项目对应的默认页面布局

    //TODO define your default loadingView, noResultView, netErrorView below And just define it in the xml layout when u need a custom layout some time   
    private static final int defaultLoadingResId = 0;
    private static final int defaultNoResultResId = 0;
    private static final int defaultNetErrorResId = 0;
    
  • Copy res/values/attrs.xml中的LoadingLayout样式到自己工程。如需自定义个别页面的布局,通过添加属性来实现

    <com.csj.loadinglayout.LoadingLayout
        android:id="@+id/loadingLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
    
        <!-- define below when needs custom layout -->
        app:loadingLayout="@layout/default_loading_layout"
        app:netErrorClickableView="@+id/clickableView"
        app:netErrorLayout="@layout/default_net_error_layout"
        app:noResultLayout="@layout/default_no_result_layout">
    
        <LinearLayout
            android:id="@+id/contentPanel"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical" />
    
    </com.csj.loadinglayout.LoadingLayout>
    
    
  • 常用API, 详见demo

    showLoading()
    showResult()
    showNoResult()
    showNetError()
    setOnNetErrorClickListener(OnClickListener)
    
  • 和ScrollView类似,只允许添加一个子View

loadinglayout's People

Contributors

cuishijie1991 avatar

Stargazers

图乐 avatar

Watchers

James Cloos avatar  avatar

Forkers

501956430

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.