Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android support v4 SwipeRefreshLayout empty view issue

SwipeRefresh is not working after setting an empty view for listview which is the only child of a SwipeRefresh layout. How to solve this issue?

like image 891
Dinesh Avatar asked Apr 09 '14 10:04

Dinesh


1 Answers

Here is the solution: You can simply use this view hierarchy :

    <FrameLayout ...>

        <android.support.v4.widget.SwipeRefreshLayout ...>

            <ListView
                android:id="@android:id/list" ... />
        </android.support.v4.widget.SwipeRefreshLayout>

        <TextView
            android:id="@android:id/empty" ...
            android:text="@string/empty_list"/>
    </FrameLayout>

Then, in code, you just call:

_listView.setEmptyView(findViewById(android.R.id.empty));

That's it.

like image 94
nitesh goel Avatar answered Nov 02 '22 20:11

nitesh goel