java - Android unfortunately has stopped when i wan't to push fragment -


I'm new to Android programming and I have this problem: if I have chosen something user, Do not want to change the menu elements (Android navigation drawer) crash my app.

This is my piece category code

  @SuppressLint ( "Nyuepi") enhances public square piece Inbox activity {@ See override public Kriattiwu (Leautinfletr Inflatr, View Group Container, bundle saved instenstate) {return inflater.inflate (R.layout.inbox_fragment, container, incorrect); }}   

This is a very simple code

What do I do with the drawer on my main square here:

  Private zero Selection item (int position) {Piece F; If (condition == 1) {f = new inbox activity (); Piece Manager Piece Manager = getFragmentManager (); Piece Transaction Feet = Piece MANAGER.beginTransaction (); ft.replace (R.id.content_frame, f); Ft.commit (); Intent activity = new intent (getApplicationContext (), InboxActivity.class); StartActivity (activity); }}   

This is very simple code and here are my errors:

  04-22 11: 18: 25.830: E / Android Random (25512) ): fatal exception: main 04-22 11: 18: 25.830: e / Android Rentaim (25512)): java.lang.RuntimeException: activity for instance ComponentInfo {com.example.android.navigationdrawerexample / com.example.android. Navigationdrawerexample.InboxActivity}: java.lang.ClassCastException: com.example.android.navigationdrawerexample.InboxActivity can not be 18: 25.830: android.app.Activity Dale E / AndroidRuntime (25512) on November 04-22: 18: : 25.830: E / AndroidRuntime android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2175) 04-22 November In R (25512): android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2299) 04-22 November: 18: 25.830: E / AndroidRuntime (25512): android.app.ActivityThread.access $ 700 (Less than the ActivityThread .java: 154) 04-22 November 18: 25.830: e / AndroidRuntime (25512): android.app.ActivityThread $ H.handleMessage (ActivityThread.java:1284) in 04-22 NOVEMBER: 18: 25.830: e / AndroidRuntime (25512): Dispute on Android.OSHandler (Message) AndroidRuntime (25512): android.app.ActivityThread.main (ActivityThread.javaitter306) 04-22 Nov: 18: 25.830: E / AndroidRuntime (25512): Java.lang.reflect.Method.invokeNative at (Native Method) 04-22 11: 18: 25.830: E / Android Random (25512): at java.lang.reflect.Method.invoke (method. Java 1111) 04-22 11: 18: 25.830: E / Androidrentaim (25512) on com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run (ZygoteInit.java:1102) 04-22 November 18: 25.830: E / AndroidRuntime (25512): com.android.internal.os.ZygoteInit.main on (ZygoteInit .java: 869) 04-22 11: 18: 25.830: E / Androindertime (25512): Dlvic. System. NetStart.main (Basic method) 04-22 11: 18: 25.830: E / Android timeTime (25512): Reason by: java.lang.ClassCastException: com.example.android.navigationdrawerexample.InboxActivity can not be inserted for Android. Apkskriyta 04-22 11: 18: 25.830: e / AndroidRuntime (25512): mentation.newActivity on android.app.Instru (Instrumentation.java:1071) 04-22 11: 18: 25.830: e / Android Rentaim (25512 ): On Android. ActiveTrade.Perform Launching Activity (ActivityTrad.Java 21) 04-22 11: 18: 25.830: E / AndroidRuntime (25512): ... 11 more   

What am I doing wrong?

As outlined in your lockback output

java.lang .ClassCastException: com.example.android.navigationdrawerexample.InboxActivity can not be put on the Android.app.Activity

are you trying to introduce their pieces as an activity

  intent activity = new intent (getApplicationContext (), inbox activity class); StartActivity (activity);   

You should remove these two lines because your piece has already been added using a fragment transaction .

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -