Navigation Drawer Activity

1

I have a problem with an application that I'm developing in Android Studio, it has the option to insert a activity (Navigation Drawer Activity) I inserted it and put a button to call it.

The problem is that when I click the button the application exits. When I create such an application (Navigation Drawer Activity) works perfectly but I can not call it in my already created project.

I gave the name of MenuActivity and I want to go from login to it by clicking the button.

The method that calls Activity :

public void click_chamaMenu(View view){
    Intent i = new Intent(Login.this,MenuActivity.class);
    startActivity(i);
}

Logcat Error:

02-04 15:10:52.814  21392-21392/com.example.celsoribeiro.titanapp E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: com.example.celsoribeiro.titanapp, PID: 21392
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.celsoribeiro.titanapp/com.example.celsoribeiro.titanapp.MenuActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2314)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2388)
            at android.app.ActivityThread.access$800(ActivityThread.java:148)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1292)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5312)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:696)
     Caused by: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
            at android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:151)
            at android.support.v7.app.ActionBarActivityDelegateBase.onCreate(ActionBarActivityDelegateBase.java:138)
            at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:123)
            at com.example.celsoribeiro.titanapp.MenuActivity.onCreate(MenuActivity.java:37)
            at android.app.Activity.performCreate(Activity.java:5953)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1128)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2267)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2388)
            at android.app.ActivityThread.access$800(ActivityThread.java:148)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1292)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5312)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:696)

----------
    
asked by anonymous 04.02.2015 / 13:37

1 answer

1

The reason for this error is that you are working with a class that extends ActionBarActivity (Deprecated in new versions) instead of AppCompatActivity .

Error line:

 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.celsoribeiro.titanapp/com.example.celsoribeiro.titanapp.MenuActivity}: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.


Try to insert android:theme="@style/Theme.AppCompat" into your AndroidManifest.xml , and make sure that the style used is compatible with AppCompat.


One friend tip I give you is to use the Material Drawer instead of the Android Studio Navigation Drawer, it is much more sophisticated and usually give less work.

    
10.09.2015 / 00:15