1

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?

Yam
  • 143
  • 2
  • 7
  • 1
    "I understand that, instead of using the Fragment class, I should use the FragmentActivity class.." this is BS... instead of `android.app.Activity` class you should use `android.support.v4.app.FragmentActivity` and instead of `android.app.Fragment` you should use `android.support.v4.app.Fragment` – Selvin May 08 '12 at 12:11
  • Thanks guys. Yes, it is my fault and I knew that I must be doing something stupid since it seems to be a "problem" only to me. – Yam May 08 '12 at 12:44

4 Answers4

6

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.

gutiory
  • 1,135
  • 5
  • 13
  • 33
4

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

Manivannan
  • 1,630
  • 1
  • 11
  • 14
2

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.

Sparky
  • 8,437
  • 1
  • 29
  • 41
  • Your reply is obviously also correct, but gutiory's reply came a little bit earlier. I did read the sample but not careful enough, and tried to jump to convert my existing app. Thanks. – Yam May 08 '12 at 12:49
0

Simple delete your gen folder...worked for me

ayush1794
  • 101
  • 1
  • 7