Reputation: 19582
In a ViewPager is there a way to display a spinner if there is nothing available to display? I.e. the PagerAdapter associated does not have any items?
Upvotes: 1
Views: 885
Reputation: 16710
I would do a check for this inside the onCreate
method of the activity where you implement the ViewPager. For example, let's say if you do have items you want to show the layout that includes the ViewPager, but if you don't you want to display a splash screen, or a simple layout with a spinner, try this:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if(mAdapter.getCount() == 0)
setContentView(R.layout.my_empty_view);
else{
setContentView(R.layout.my_pager_view);
}
}
Upvotes: 2