Android Question Sliding Drawer in B4xPages

Good day!

I am having problem with implementing the sliding drawer in a b4xpage.

I used "Root" since I cannot use "Activity" in the drawer initialization parameter.


B4X:
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Drawer.Initialize(Me, "Drawer", Root, 300dip)
    Drawer.CenterPanel.LoadLayout("CLV")  'Just to avoid confusion, "CLV" here is really the layout.
    ToolbarHelper.Initialize
    ToolbarHelper.ShowUpIndicator = True
    Dim bd As BitmapDrawable
    bd.Initialize(LoadBitmap(File.DirAssets, "hamburger.png"))
    ToolbarHelper.UpIndicatorDrawable = bd
    ACToolBarLight1.InitMenuListener
    Drawer.LeftPanel.LoadLayout("Left_drawer")
    
    ListView1.AddTwoLinesAndBitmap("For Acceptance", "", LoadBitmap(File.DirAssets, "For Acceptance.png"))
    ListView1.AddTwoLinesAndBitmap("Order History", "", LoadBitmap(File.DirAssets, "Order History.png"))
    ListView1.AddTwoLinesAndBitmap("Logout", "", LoadBitmap(File.DirAssets, "Logout.png"))
End Sub

Also, the error that it's giving me is:

Logger connected to: HUAWEI STK-L22
--------- beginning of crash
--------- beginning of system
--------- beginning of main
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
*** Service (httputils2service) Create ***
** Service (httputils2service) Start **
java.lang.ClassCastException: Nadej.Shopper.current_order cannot be cast to android.view.View
at anywheresoftware.b4a.objects.B4XViewWrapper.asViewWrapper(B4XViewWrapper.java:88)
at anywheresoftware.b4a.objects.B4XViewWrapper.getWidth(B4XViewWrapper.java:141)
at Nadej.Shopper.b4xdrawer._initialize(b4xdrawer.java:123)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.debug.Debug.delegate(Debug.java:262)
at Nadej.Shopper.current_order._b4xpage_created(current_order.java:434)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.debug.Debug.CallSub4(Debug.java:318)
at anywheresoftware.b4a.debug.Debug.CallSubNew2(Debug.java:285)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.keywords.Common.CallSubDebug2(Common.java:1055)
at Nadej.Shopper.b4xpagesmanager._createpageifneeded(b4xpagesmanager.java:1022)
at Nadej.Shopper.b4xpagesmanager._showpageandremovepreviouspages(b4xpagesmanager.java:448)
at Nadej.Shopper.b4xpages._showpageandremovepreviouspages(b4xpages.java:30)
at Nadej.Shopper.b4xmainpage$ResumableSub_adminLogin.resume(b4xmainpage.java:235)
at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resumeAsUserSub(DebugResumableSub.java:48)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:193)
at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resume(DebugResumableSub.java:43)
at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:267)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:137)
at anywheresoftware.b4a.BA$2.run(BA.java:387)
at android.os.Handler.handleCallback(Handler.java:888)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:213)
at android.app.ActivityThread.main(ActivityThread.java:8178)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1101)

Thanks for the assistance!
 
Don't use AppCompat with B4XPages. It is not needed.

I don't understand this error. Do you have a module named root?

Example of B4XPages + B4XDrawer: [B4X] B4XPages + B4XDrawer
In this part.
B4X:
Drawer.Initialize(Me, "Drawer", Activity, 300dip) 'This is how it should be

'But since it is not accepting "Activity", this is why I did this

Drawer.Initialize(Me, "Drawer", Root, 300dip)

'What is the work around here, by the way?

I'll try not to use AppCompat
 
Upvote 0
Top