Sunday, 8 September 2013

Why is GridViews adapter null but not Listviews? (In ViewPager fragments)

Why is GridViews adapter null but not Listviews? (In ViewPager fragments)

I have a couple of fragments in a viewpager and each time their
onViewCreated() is called I set the adapter unless it has already been
set.
I check this by
getListAdapter() == null ? setAdapter() : //Otherwise do nothing
This works great. However when I have a GridView instead of the ListView
and I perform the same actions, the adapter is always null so it needs to
be set each time the fragment is created. Why is this?
mGridView.getAdapter() == null ? setAdapter() : //Otherwise do nothing

No comments:

Post a Comment