I\'ve implemented SwipeRefreshLayout into my app but it can only hold one direct child which should be the listview. I\'m trying to figure out how to add an emp
There is no need for any workaround.
You can simply use this view hierarchy :
Then, in code, you just call:
_listView.setEmptyView(findViewById(android.R.id.empty));
That's it.
EDIT: If you wish to be able to swipe-to-refresh even when the empty view is shown, you will have to somehow avoid hiding the ListView, so you could use a customized ListView that has this function inside:
@Override
public void setVisibility(final int visibility)
{
if(visibility!=View.GONE||getCount()!=0)
super.setVisibility(visibility);
}
Together with the solution I wrote, the swipe-to-refresh is shown no matter how many items you are showing.
Of course, if you really want to hide the ListView, you should change the code. Maybe add "setVisibilityForReal(...)" :)