ViewPager with Fragment, OnCreateView called multiple time.

SiflouSiflou USMember ✭✭

Hey Guys,

Heres my problem, I have a viewPager that is linked with my data in a list. for example the list at index 0, contains data for the first fragment, the indice 1 is the second fragment and etc. So when i make a new fragment, I dot it like this :

public override Fragment GetItem (int position)
{
return new DashboardFragment (mActivity,position);
}

In my fragment, in the onCreate, I load the data from the list at the index position. But this creates a problem because sometime, when I swap, the onCreateView will get called and will refresh the thirdElement, but it didnt create a new fragment, so it took the first fragment that has the position to 0, so that refresh my third fragment with the data of the first one. Can some one help me please, I dont know what to do about it. Thanks a lot !

Claude

Posts

  • ChrisHonselaarChrisHonselaar NLBeta ✭✭✭

    I'm finding it hard to follow what you are doing exactly. Can you share a bit more code?

  • SiflouSiflou USMember ✭✭

    Hey Chris, Thanks for the fast awnser. I found my awnser, in fact the problem was from another source than the fragment 0 being instantied in the position's 2 fragment, it was a mislinking by my part in my code with my data list. Sorry for your time, I really tought that the ViewPager caused that problem. Thanks anyway, really appreciated :)

Sign In or Register to comment.