I am using a ViewPager (android.v4.support package), and on of its
screens I have multiple fragments views. Using a separate res layout
file for fragments screen works fine (inflate layouts in PagerAdapter
and provide the view for the ViewPager screen).

But I wanted to be able to easily add/ remove fragments in the future
so I preferred to use the fragments (instantiation) usage via source
code instead of layout res file to avoid manually changing ViewPager's
screens layout by adding more fragments. So I decided to use GridView
for easy handling of fragments addition/ removal and also for auto
ordering and layout of fragments. But I encountered some problem in
using fragments via custom adapter (extends BaseAdapter) for gridview.

So now I instantiate all fragments manually in gridview adapter's
constructor, and add them to the enclosing activity. But in the
GridView adapter's function

public View getView(int position, View arg1, ViewGroup arg2)
{
    myFragment[position].getView();
}

function, I get error as it returns null. I think that it gets called
before the onCreateView() function of Fragments is called, and thus
returns null.

Could anyone suggest any clue for this?
Or may be any other better way for my requirement (of managing easy
multiple fragments) than using GridView for fragments (since GridView
adapters needs view components in their implementation, and fragments
might not be suitable for it)

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to