Question

I try to use the Android compatibility library (or now called the support library) v4 for pre-honeycomb android devices. I understand that, instead of using the Fragment class, I should use the FragmentActivity class. According to all the tutorials I can find, I can use the onCreateView method as in the Fragment class:

public View onCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)

However, the onCreateView method in the FragmentActivity seems to be different. The one I inherit from is:

public View onCreateView (String name, Context context, AttributeSet attrs)

This version is actually listed in the Android reference of the FragmentActivity class.
Seems all tutorials I can find do not state this difference, and all are calling the one in the Fragment class. Am I mistaking something here that I should be somehow able to call the onCreateView of the Fragment class version?

Était-ce utile?

La solution

I think this is wrong:

I understand that, instead of using the Fragment class, I should use the FragmentActivity class.

You should use FragmentActivity class insted of Activity class. In FragmentAcivity class it's enough that you override onCreate method.

Autres conseils

FragmentActivity and Activty are same. FragmentActivity is for Version (below 4)which are supports Fragment by using android.support.v4.jar . For Versions from 4 there is no FragmentActivity..u can check it out. FragmentActivity is for Calling showing Fragments..so u should not extends FragmentActivity when u develop fragment View. Fragments are part of the FragmentActivity.u can have more framgents. for ur doubt:check this http://developer.android.com/reference/android/app/Activity.html#onCreateView%28android.view.View,%20java.lang.String,%20android.content.Context,%20android.util.AttributeSet%29

You've got it a little switched around. Fragment is still Fragment. Activity becomes FragmentActivity. Have a peek at the sample code that comes with the Android Compatibility Library. In particular, see FragmentLayoutSupport.java.

Simple delete your gen folder...worked for me

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top