2

I am using this tutorial to create sliding menu for application but I get error in the following lines, and I am unable to solve it:

getFragmentManager();
getActionBar();

After adding AppCompat to project many problems can resolve.

My Manifes:

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="11" />

My class extends from Activity. After changed that to ActionBarActivity and :

getFragmentManager();

to

getSupportFragmentManager();

I get an error as:

 512-512/ir.tsms.app E/AndroidRuntime﹕ FATAL EXCEPTION: main
    java.lang.ExceptionInInitializerError
            at android.support.v7.app.ActionBarActivityDelegate.createDelegate(ActionBarActivityDelegate.java:58)
            at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:97)
            at ir.tsms.app.tsms.MyActivity.onCreate(MyActivity.java:46)

Log cats:

  cannot find symbol
  symbol:   method getSupportFragmentManager()`  

  cannot find symbol
  symbol:   method getFragmentManager()`
Maihan Nijat
  • 9,054
  • 11
  • 62
  • 110
  • post some code so that we can help you – Nitin Oct 16 '14 at 03:52
  • I suggest you that when you want to create a new android project, uncheck "Create Activity" option available in New Android Application wizard. After creating project you have to manually create package name and you have to specify activity and and intent filters manually. In this case android.support.v7 will not be added automatically. – Ashish Tiwari Oct 16 '14 at 04:10
  • @AshishTiwari are you have simple sample like with that? i can not resolve problem –  Oct 16 '14 at 04:33
  • This example(http://www.androidhive.info/2013/11/android-sliding-menu-using-navigation-drawer) has a best sample, I have tried this. It does not require any extra things to modify. Just download and import it on your workspace properly. – Ashish Tiwari Oct 16 '14 at 04:49

1 Answers1

2

Your activity should extends FragmentActivity o you can use getSupportFragmentManager() (on older device) if you are targeting only newer device use (extend Activity): getFragmentManager()

Unii
  • 1,587
  • 15
  • 33