Android Question Problem with ACToolBarDark (AppCompat with ToolBar) in layout.

VeraVera

Member
Licensed User
Hi Erel

I indicate you the following problem.

I want to use the ACToolBarDark1 in my project but it only works as long as I call the layout from the Main module and not from another module.

If I try to make the layout call with ACToolBarDark1 from a module other than the Main module, I get the following error:

'*****
p_activity_create (java line: 347)
java.lang.RuntimeException: java.lang.ClassCastException: b4a.example.p cannot be cast to android.support.v7.app.AppCompatActivity
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:170)
at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:209)
at b4a.example.p._activity_create(p.java:347)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:186)
at b4a.example.p.afterFirstLayout(p.java:102)
at b4a.example.p.access$000(p.java:17)
at b4a.example.p$WaitForLayout.run(p.java:80)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:153)
at android.app.ActivityThread.main(ActivityThread.java:5313)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:833)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:600)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassCastException: b4a.example.p cannot be cast to android.support.v7.app.AppCompatActivity
at de.amberhome.objects.appcompat.ACToolBarWrapper.DesignerCreateView(ACToolBarWrapper.java:103)
at anywheresoftware.b4a.objects.CustomViewWrapper.AfterDesignerScript(CustomViewWrapper.java:70)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:162)
... 17 more
java.lang.RuntimeException: java.lang.ClassCastException: b4a.example.p cannot be cast to android.support.v7.app.AppCompatActivity
'****

The code that I use in the main module replicates it in the new module.

My project requires many layouts and not all of them are going to need the side menu, so how can I use the ACToolBarDark1 in several layouts?

Using a ScrollView in the main layout (the one that is called from the main module) and loading a layout as needed is not viable since the actions of each layout would have to contain it in the main module and my project is very extensive.

I hope you can help me or guide me.

Thank you very much.

PD: I use B4A version 7.8
 

DonManfred

Expert
Licensed User
Longtime User
java.lang.RuntimeException: java.lang.ClassCastException: b4a.example.p cannot be cast to android.support.v7.app.AppCompatActivity
In your other module (which NEEDS to be an Activity) you need to use the same as in main. You need to extend the Activity to be an AppCompat Activity. Check AppCompat Tutorial
 
Upvote 0
Top