These days found a problem I used Getfragmentmanager () Get Fragmentmanager can not put into fragmentpageradapter inside. Because the fragmentpageradapter inside the structure parameter must be the Fragmentmanager under the V4 package, And I activty inside Getfragmentmanager get is under the app package Fragmentmanager there is a conflict
The general solution is not to inherit activity but to inherit fragmentactivity. But I just don't want to actvity. Because Fragmentactivity is compatible with the 3.0 version I don't even think about 3.0, Android first half fragment Analysis 3.0 is only 6% of the share, many apps do not consider 2.3 what the direct lowest 4.0.
I am doing a ble project because BLE is based on Android 4.3, so my project minimum version is 4.3 projects used to Viewpager time with the Fragmentpageradapter adapter, However, it is found that the default Fragmentpageradapter constructor parameter must be used for the Fragmentmanager under the V4 package. And since I've developed based on 4.3, I'm managing the fragment interface directly with activity. I might say why not use F, We know that fragmentactivity is the ANDROID-SUPPORT-V4 Compatibility Pack. Since the Compatibility Pack is for compatibility with 3.0 versions I've been to 4.3. Why do I have to be a little bit more compatible with 3.0?
The question is summarized below:
Because it is the minimum version 4.3 so I use the fragment time do not want to use fragmentactivity directly with the actiity more convenient to define the base class is also more convenient.
The problem is that the fragment Fragmentpageradapter adapter must pass a parameter to the Fragmentmanager of the V4 package by default, and I use the fragmentmanager of the activity to get the app package.
It's messy. And found there is no fragmentpageradapter under the app package. Really almost didn't scold Google brain residue.
Solution directly to the V4 report to find Fragmentpageradapter source to copy all of his own set up a class, the inside of all the import Fragmentmanager into the app package to solve the problem,
, finally still do not believe that Google has such a brain residue, finally found in the V13 package under the Fragmentpageradapter this class used to Fragmentmanager is the app package Fragmentmanager, then the V13 package poured in
You can easily use the Actvity class to get the Fragmentmanager implementation,
In case you think that using v13 bag only use such a class waste, then just pull down the fragmentpageradapter of the V13 bag and copy it and omit it.
So remark:
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
About the app. Fragmentmanager and v4 package of Fragmentpageradapter conflict