Home > Mobile >  ViewPagter + fragments
ViewPagter + fragments

Time:10-05

ViewPager binding FragmentPagerAdapter setArguments value, of the use of two fragments are created through the Log and call the fragments of onCreate in onCreate through getArguments value data of sequence is fragment1, fragment2, after the assignment to each Fragment in the results of the two fragments in the TextView TextView shows are fragment2 this value and why?

CodePudding user response:

Print getArguments yourself if, as well as the data is wrong when you add fragments to the adapter

CodePudding user response:

Add fragments are new added a new object does not exist the same object

CodePudding user response:

Will you code it

CodePudding user response:

CodePudding user response:

Your frame is not what you have written the value of death? You can see in your activity every time you slip into fragments of value is how much, can break point and have a look

CodePudding user response:

If you give TextView assignment are 2 fragments to create all call the onCreate method mSiteId printed in turn is 1, 2, if mSiteId call loadDate method drop-down refresh in time this time for 2 if I was the first Fragment refresh mSiteId should be 1, the second fragments of mSiteId is 2
  • Related