A library for showing different types of layouts when a list view is empty

Overview

Android Empty Layout

Please note that this project is not being maintained now. Hopefully a new version will be available soon.

A library for showing different types of layouts when a list view is empty. These layouts can be shown when,

  • the list is loading
  • the list has no item to display
  • an error occured trying to load items

Loading animation is also supported.

Screenshots

alt text alt text alt text alt text

Usage

  1. Import the library project into your workspace.
  2. Use the imported project as a library for your project.
  3. In the onCreate event of your activity use the following code.
mListAdapter.clear();
EmptyLayout emptyLayout = new EmptyLayout(this, getListView());
  1. When you want to show the loading animation, use this code.
mListAdapter.clear();
emptyLayout.showLoading();
  1. When you want to show any error, use this code.
mListAdapter.clear();
emptyLayout.showError();
  1. When your list doesn't have any item to show, use this code.
mListAdapter.clear();
emptyLayout.showEmpty();

Thats all you have to do to use this library. You may want to customize its behavior though.

P.S. Make sure you always clear the list adapter before calling showEmpty, showLoading and showError. The list have to empty after all.

Customization

There are bunch of methods to let you customize this pattern. Use the methods like this.

emptyLayout.setLoadingMessage("Please wait...");

Some useful methods are given below

  • showEmpty
  • showLoading
  • showError
  • setLoadingView
  • setEmptyView
  • setErrorView
  • setLoadingAnimation
  • setErrorMessage
  • setLoadingMessage
  • setEmptyMessage
  • setEmptyViewButtonClickListener
  • setLoadingViewButtonClickListener
  • setErrorViewButtonClickListener
  • setShowEmptyButton
  • setShowLoadingButton
  • setShowErrorButton

and there is more...

Example

A simple example is also available.

License

Copyright 2014 Raquib-ul-Alam

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.
Comments
  • Can u make it compatible to use with RecycleView??

    Can u make it compatible to use with RecycleView??

    Hi Alam,

    First of all thanks for the awesome library.Can u please make it compatible with the recycleview if possible.It would be great to use it with recycleview.

    opened by hardikamal 0
  • Advice: the 'Empty View' should stay in center of list instead of its parent container

    Advice: the 'Empty View' should stay in center of list instead of its parent container

    hello, I found a problem while learning your code. see the usage below: image then, you add "Empty View" into the parent of mListView (see EmptyLayout.java:463) You view looks like this: image Obviously, I want the picture in center of list view instead of its parent.

    image

    Now I make a little change at EmptyLayout.java:changeEmptyType(), you can easily understand.

    ~~~
        // insert views in the root view
        if (!mViewsAdded) {
            RelativeLayout.LayoutParams lp = new LayoutParams(mListView.getWidth(), mListView.getHeight());
            lp.topMargin = mListView.getTop();
            lp.leftMargin = mListView.getLeft();
            RelativeLayout rl = new RelativeLayout(mContext);
            rl.setLayoutParams(lp);
            if (mEmptyView!=null) {
                rl.addView(mEmptyView);
                RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) mEmptyView.getLayoutParams();
                layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
                mEmptyView.setLayoutParams(layoutParams);
            }
            if (mLoadingView!=null) {
                rl.addView(mLoadingView);
                RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) mLoadingView.getLayoutParams();
                layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
                mLoadingView.setLayoutParams(layoutParams);
            }
            if (mErrorView!=null) {
                rl.addView(mErrorView);
                RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) mErrorView.getLayoutParams();
                layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
                mErrorView.setLayoutParams(layoutParams);
            }
            mViewsAdded = true;
    
            ViewGroup parent = (ViewGroup) mListView.getParent();
            parent.addView(rl);
            mListView.setEmptyView(rl);
        }
    ~~~
    

    Thanks for your good code.

    opened by walfud 0
  • Advice: the 'Empty View' should stay in center of list instead of its parent container.

    Advice: the 'Empty View' should stay in center of list instead of its parent container.

    hello, I found a problem while learning your code. see the usage below: image then, you add "Empty View" into the parent of mListView (see EmptyLayout.java:463) You view looks like this: image Obviously, I want the picture in center of list view instead of its parent.

    image

    Now I make a little change at EmptyLayout.java:changeEmptyType(), you can easily understand.

    ~~~
        // insert views in the root view
        if (!mViewsAdded) {
            RelativeLayout.LayoutParams lp = new LayoutParams(mListView.getWidth(), mListView.getHeight());
            lp.topMargin = mListView.getTop();
            lp.leftMargin = mListView.getLeft();
            RelativeLayout rl = new RelativeLayout(mContext);
            rl.setLayoutParams(lp);
            if (mEmptyView!=null) {
                rl.addView(mEmptyView);
                RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) mEmptyView.getLayoutParams();
                layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
                mEmptyView.setLayoutParams(layoutParams);
            }
            if (mLoadingView!=null) {
                rl.addView(mLoadingView);
                RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) mLoadingView.getLayoutParams();
                layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
                mLoadingView.setLayoutParams(layoutParams);
            }
            if (mErrorView!=null) {
                rl.addView(mErrorView);
                RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) mErrorView.getLayoutParams();
                layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
                mErrorView.setLayoutParams(layoutParams);
            }
            mViewsAdded = true;
    
            ViewGroup parent = (ViewGroup) mListView.getParent();
            parent.addView(rl);
            mListView.setEmptyView(rl);
        }
    ~~~
    

    Thanks for your good code.

    opened by walfud 4
  • Crash the SwipeRefreshLayout

    Crash the SwipeRefreshLayout

    SwipeRefreshLayout (from support v4 19.1) can has only 1 child. Currently my solution is to check if the parent is that, and then get its parent (should also check if he has parent, but in my code it always has a parent):

    ViewGroup parent = (ViewGroup) mListView.getParent();
                // Start editing
                if (parent instanceof SwipeRefreshLayout) {
                    parent = (ViewGroup) parent.getParent();
                }
                // End editing
    
    opened by yoavst 1
  • Empty button not shown

    Empty button not shown

    mEmptyLayout.setEmptyMessage(emptyMessage);
    mEmptyLayout.setShowEmptyButton(showEmptyButton);
    mEmptyLayout.setEmptyButtonClickListener(listener);
    mEmptyLayout.showEmpty();
    

    That is my code, when showEmptyButton is true. The problem is that the empty button isn't shown

    opened by yoavst 6
Releases(android-empty-layout-v1.1)
Owner
Raquib-ul Alam (Kanak)
Hybrid of two realms: android/kotlin and machine learning
Raquib-ul Alam (Kanak)
ViewStateLayout - Easy way to manage common state templates like loading, empty, error etc.!

ViewStateLayout Easy way to manage common state templates like loading, empty, error etc.! How to Step 1. Add the JitPack repository to your build fil

Kamrul Hasan 7 Dec 15, 2022
[UNMAINTAINED]: AndroidMosaicLayout is android layout to display group of views as grid consists of different asymmetric patterns (90 different patterns).

AndroidMosaicLayout AndroidMosaicLayout is android layout to display group of views in more that 90 different patterns. What is AndroidMosaicLayout? I

Adham Enaya 474 Nov 12, 2022
A library that easily allows you to mask layouts/viewgroups

Maskable Layout Overview ======================= The Maskable Layout is a simple framelayout that allows you to easily mask views and viewgroups. You

Christophe Smet 654 Dec 2, 2022
Repositório para criar layouts e chamar na activity main e melhorar um dos pontos fracos meu (layout).

Repositório para criar layouts e chamar na activity main e melhorar um dos pontos fracos meu (layout). Não se preocupe com os tipos malucos de layouts

Murillo Alves da Silva 1 Dec 14, 2021
A 3D Layout for Android,When you use it warp other view,it can became a 3D view,一秒让你的view拥有3D效果!

ThreeDLayout A 3D Layout,When you use it warp other view,it can became a 3D view 中文文档 preview USAGE 1.compile library allprojects { repositories {

androidwing 490 Oct 27, 2022
This assignment gives you basically a post list and its detail with comments.🚀

Android Assignment ?? Description This assignment gives you basically a post list and its detail with comments. ?? Features Users can see random post

Okan AYDIN 31 Dec 20, 2022
A wave view of android,can be used as progress bar.

WaveView ![Gitter](https://badges.gitter.im/Join Chat.svg) A wave view of android,can be used as progress bar. Screenshot APK demo.apk What can be use

Kai Wang 1.3k Dec 28, 2022
TileView is a subclass of android.view.ViewGroup that asynchronously displays, pans and zooms tile-based images. Plugins are available for features like markers, hotspots, and path drawing.

This project isn't maintained anymore. It is now recommended to use https://github.com/peterLaurence/MapView. MapView is maintained by Peter, one of o

Mike Dunn 1.5k Nov 21, 2022
Android component which presents a dismissible view from the bottom of the screen

BottomSheet BottomSheet is an Android component which presents a dismissible view from the bottom of the screen. BottomSheet can be a useful replaceme

Flipboard 4.5k Dec 28, 2022
Show triangle view.

TriangleLabelView Show triangle view. How to Use To see how the TriangleLabelView are added to your xml layouts, check the sample project. <jp.shts.an

Shota Saito 877 Dec 6, 2022
VoronoiView is a view (ViewGroup) that allows you to add and display views inside Voronoi diagram regions.

Vorolay VoronoiView is a view (ViewGroup) that allows you to add and display views inside Voronoi diagram regions. [Voronoi diagram] (https://en.wikip

Daniil Jurjev 918 Dec 4, 2022
A swipeable - auto resizing view group for android

SwipeableLayout A swipeable - auto resizing view group for android Usage build.gradle compile 'com.wmbest.widget:swipeable-layout:1.0.+@aar' -- or --

Bill Best 114 Nov 25, 2022
Material Design Search View Layout, now implemented in Google Maps, Dialer, etc

THIS PROJECT IS DEPRECATED Component is not maintained anymore. Implementation of Lollipop+ Dialer and Google Maps. DEMO Add in View Add to your layou

Sahil Dave 1.1k Dec 22, 2022
Bubble View for Android.

BubbleLayout Bubble View for Android with custom stroke width and color, arrow size, position and direction. BubbleLayout Extends the FrameLayout. Gra

Masayuki Suda 964 Dec 28, 2022
An Android library that help you to build app with swipe back gesture.

SwipeBackLayout An Android library that help you to build app with swipe back gesture. Demo Apk GooglePlay Requirement The latest android-support-v4.j

ike_w0ng 6.1k Dec 29, 2022
Android library used to create an awesome Android UI based on a draggable element similar to the last YouTube graphic component.

Draggable Panel DEPRECATED. This project is not maintained anymore. Draggable Panel is an Android library created to build a draggable user interface

Pedro Vicente Gómez Sánchez 3k Jan 5, 2023
SwipeBack is an android library that can finish a activity by using gesture.

SwipeBack SwipeBack is a android library that can finish a activity by using gesture. You can set the swipe direction,such as left,top,right and botto

Eric 1.7k Nov 21, 2022
A very simple arc layout library for Android

ArcLayout A very simple arc layout library for Android. Try out the sample application on the Play Store. Usage (For a working implementation of this

ogaclejapan 1.4k Dec 26, 2022