Reputation: 37474
many tutorials on Fragment
found on the web (like this one) use FragmentActivity
. It seems to be the static way of using Fragment
, as opposed to the dynamic way using FragmentTransaction
to load Fragment
s in a container in a normal Activity
.
I'm using API 12 and FragmentActivity
is not there (it's in android.support.v4.app
).
So if I don't use the Android support package, I can only manage Fragment
dynamically, right? Why has FragmentActivity
disappeared?
Thanks
Upvotes: 2
Views: 3173
Reputation: 1006914
It seems to be the static way of using Fragment, as opposed to the dynamic way using FragmentTransaction to load Fragment s in a container in a normal Activity.
That is completely wrong.
FragmentActivity
is for use with the Android Support package, if you wish to use fragments prior to API Level 11. Both static (<fragment>
in a layout) and dynamic (FragmentTransaction
) fragments are supported both by FragmentActivity
and by Activity
(the latter only on API Level 11 and higher).
I'm using API 12 and FragmentActivity is not there (it's in android.support.v4.app).
Add the Android Support package to your project. For example, from Eclipse, and right-click over the project, choose Android Tools > Add Support package from the context menu.
So if I don't use the Android support package, I can only manage Fragment dynamically, right?
No, you can use static or dynamic fragments with Activity
on API Level 11.
Why has FragmentActivity disappeared?
It has not disappeared. For ease of use, they integrated the Android Support package JavaDocs into the main JavaDocs. Whenever you see a class in an android.support
package, you know that it is from the Android Support package.
Upvotes: 7