Android Question b4xpages error while trying to add menu list on tabstrip

Makumbi

Well-Known Member
Licensed User
Please help iam getting error while trying to add menu list

B4X:
B4XPages.AddMenuItem("Parent Profile", "mnu1")
    B4XPages.AddMenuItem("Accounts", "mnu2")
    B4XPages.AddMenuItem("Academics", "mnu3")
    B4XPages.AddMenuItem("Communication Book", "mnu4")
    B4XPages.AddMenuItem("Notice Board", "mnu5")
    B4XPages.AddMenuItem("New Admissions", "mnu6")
    B4XPages.AddMenuItem("Home work Download", "mnu7")
    B4XPages.AddMenuItem("Digital Lessons", "mnu11")
    B4XPages.AddMenuItem("Get Class Teacher Details", "mnu8")
    B4XPages.AddMenuItem("Must Read", "mnu9")
    B4XPages.AddMenuItem("Help", "mnu10")

Here is the error that comes up
B4X:
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Database size = 4096
Error occurred on line: 294 (B4XPagesManager)
java.lang.NullPointerException: Attempt to read from field 'b4a.example.b4xpagesmanager$_b4xpageparent b4a.example.b4xpagesmanager$_b4xpageinfo.Parent' on a null object reference
    at b4a.example.b4xpagesmanager._addmenuitem(b4xpagesmanager.java:213)
    at b4a.example.b4xpages._addmenuitem(b4xpages.java:84)
    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 b4a.example.b4xmainpage._b4xpage_created(b4xmainpage.java:146)
    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 b4a.example.b4xpagesmanager._createpageifneeded(b4xpagesmanager.java:1063)
    at b4a.example.b4xpagesmanager._showpage(b4xpagesmanager.java:420)
    at b4a.example.b4xpagesmanager._addpage(b4xpagesmanager.java:248)
    at b4a.example.b4xpagesmanager._addpageandcreate(b4xpagesmanager.java:262)
 

Makumbi

Well-Known Member
Licensed User
Use the comment link at the top of B4XMainPage to create the zip:
B4X:
'Ctrl + click to export as zip: ide://run?File=%B4X%\Zipper.jar&Args=Project.zip

I ran your program and didn't get any error.

When i tried to unblock this
B4X:
'Ctrl + click to export as zip: ide://run?File=%B4X%\Zipper.jar&Args=Project.zip
according to your advise i now get this error
B4X:
B4XMainPage - 6: run?file is not a valid identifier.
i have also attached another small project which shows you this error
B4X:
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
Database size = 4096
Error occurred on line: 294 (B4XPagesManager)
java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.keywords.Common.CallSubDebug2(Common.java:1055)
    at b4a.example.b4xpagesmanager._createpageifneeded(b4xpagesmanager.java:1063)
    at b4a.example.b4xpagesmanager._showpage(b4xpagesmanager.java:420)
    at b4a.example.b4xpagesmanager._addpage(b4xpagesmanager.java:248)
    at b4a.example.b4xpagesmanager._addpageandcreate(b4xpagesmanager.java:262)
    at b4a.example.b4xpagesmanager._initialize(b4xpagesmanager.java:168)
    at b4a.example.main._activity_create(main.java:420)
    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 b4a.example.main.afterFirstLayout(main.java:105)
    at b4a.example.main.access$000(main.java:17)
    at b4a.example.main$WaitForLayout.run(main.java:83)
    at android.os.Handler.handleCallback(Handler.java:873)
    at android.os.Handler.dispatchMessage(Handler.java:99)
 

Attachments

  • Backup KABOJJAAPP 2021-03-27 10.58.zip
    210.7 KB · Views: 168
Upvote 0

Mahares

Expert
Licensed User
Longtime User
iam getting error while trying to add menu list
I think the reason you did not find the error is because Makumbi commented the code that is showing the error:
I ran your program and didn't get any error.
I think I found your problem. See code below:
B4X:
B4XPages.AddMenuItem(Me,"mnu1")   'tag is by default set to the Title: mnu1
B4XPages.AddMenuItem(Me,"mnu2")

Sub B4XPage_MenuClick (Tag As String)
    If Tag = "mnu1" Then   'tag is by default set to the Title: mnu1
        B4XPages.ShowPage("Helpus")
    End If
End Sub
@Makumbi, don't comment the problem code. It would be hard for someone to find your issue especially, someone like Erel who has little time to answer hundreds of posts daily
 
Upvote 0

Makumbi

Well-Known Member
Licensed User
I think the reason you did not find the error is because Makumbi commented the code that is showing the error:

I think I found your problem. See code below:
B4X:
B4XPages.AddMenuItem(Me,"mnu1")   'tag is by default set to the Title: mnu1
B4XPages.AddMenuItem(Me,"mnu2")

Sub B4XPage_MenuClick (Tag As String)
    If Tag = "mnu1" Then   'tag is by default set to the Title: mnu1
        B4XPages.ShowPage("Helpus")
    End If
End Sub
@Makumbi, don't comment the problem code. It would be hard for someone to find your issue especially, someone like Erel who has little time to answer hundreds of posts daily

Thank you very much
 
Upvote 0

Makumbi

Well-Known Member
Licensed User
Thank You maharez you advised me to use customlistview. but my challenge is maintaining my old colors which i was using in the listview example
Because under customlistview when i try to implement them they dont come out when
below are the colors i used in the list view and i would want to maintain the same in the customlistview
first color

B4X:
#FF0760F1

second color
B4X:
#FFF900AC
 

Attachments

  • Screenshot_1616844625.png
    Screenshot_1616844625.png
    178.1 KB · Views: 184
Upvote 0

Mahares

Expert
Licensed User
Longtime User
i would want to maintain the same in the customlistview
You can put the data in a list and use the gradient drawable to set the background for each item panel. See below code. You may of course change the colors as you wish.
B4X:
Dim gd As GradientDrawable
        Dim clrs(2) As Int
        clrs(0)= xui.Color_ARGB(255, 0,0,255)  'you can change the 1st and 2nd color in the array
        clrs(1)= xui.Color_ARGB(255, 255,7,96)
        gd.Initialize("LEFT_RIGHT", clrs)
Dim MyList As List
    MyList.Initialize
    MyList.AddAll(Array ("Parent Profile", "Change Number", "Send Multiple Classes To Your Email. " _
    & "This Is a long sentence For testing", "This item demonstrates that when you use xClv with the AddTextItem, " _
    & "the item panel height " _
    & "automatically expands to show all the text without truncation"))
    For i=0 To MyList.Size -1
        xClv.AddTextItem(MyList.Get(i), MyList.Get(i))
        Dim p As Panel = xClv.GetPanel(i)  'the height of panel is automatically adjusted to text length
        p.Background= gd
    Next
Added this a few hours later:
What you want to achieve can also be done in the xClv Base Backgound properties designer without the code above The drawable needs set at gradient
drawable. then set the orientation , then set1st and 2nd colors. Also set the xClv divider color to transparent.
without doing it programmatically with gd.
 

Attachments

  • Makumbi032821.png
    Makumbi032821.png
    51.4 KB · Views: 184
Last edited:
Upvote 0

MikeSW17

Active Member
Licensed User
Longtime User
When i tried to unblock this
B4X:
'Ctrl + click to export as zip: ide://run?File=%B4X%\Zipper.jar&Args=Project.zip
according to your advise i now get this error
B4X:
B4XMainPage - 6: run?file is not a valid identifier.
i have also attached another small project which shows you this error

You don't alter (unblock) the 'Comment. Just move the mouse pointer over it and Ctrl-click it.
The IDE recognises it despite it being a comment line.
 
Upvote 0
Top