Android Question As_Tabmenuadvanced crashing on setting index and corner radius on Android

mcqueccu

Well-Known Member
Licensed User
Longtime User
I recently updated the library and on Android, some users reported crash on parts of the apps that uses the TabmenuAdvanced.
Through my debugging I realized it was crashing if you add this. B4J and B4i Okay.

B4X:
    AS_TabMenuAdvanced1.Index = 0
    AS_TabMenuAdvanced1.CornerRadius = 20


B4X:
Logger connected to:  TECNO
--------- beginning of main
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
** Activity (main) Resume **
Error occurred on line: 591 (AS_TabMenuAdvanced)
java.lang.IllegalArgumentException: width and height must be > 0
    at android.graphics.Bitmap.createBitmap(Bitmap.java:1253)
    at android.graphics.Bitmap.createBitmap(Bitmap.java:1092)
    at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:805)
    at anywheresoftware.b4a.objects.drawable.CanvasWrapper$BitmapWrapper.Resize(CanvasWrapper.java:568)
    at anywheresoftware.b4a.objects.B4XViewWrapper$B4XBitmapWrapper.Resize(B4XViewWrapper.java:678)
    at b4a.example.as_tabmenuadvanced._tabclick(as_tabmenuadvanced.java:1993)
    at b4a.example.as_tabmenuadvanced._setindex(as_tabmenuadvanced.java:239)
    at b4a.example.b4xmainpage$ResumableSub_B4XPage_Created.resume(b4xmainpage.java:120)
    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:157)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:201)
    at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resume(DebugResumableSub.java:43)
    at anywheresoftware.b4a.keywords.Common$14.run(Common.java:1748)
    at android.os.Handler.handleCallback(Handler.java:942)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loopOnce(Looper.java:204)
    at android.os.Looper.loop(Looper.java:291)
    at android.app.ActivityThread.main(ActivityThread.java:8129)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:601)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1136)
 

Attachments

  • AsTBM_ADv.zip
    492.6 KB · Views: 111
Solution
I recently updated the library
Yes, I have extended the set index property so that you do not have to use ".Refresh" to change the index.

But this property call is also useless because it sets the index to 0 by default when creating the view.

Why it crashes in your project is as follows:
You do this:
B4X:
    AS_TabMenuAdvanced1.AddTab("",xui.LoadBitmap(File.DirAssets,"home_active.png"),xui.LoadBitmap(File.DirAssets,"home_inactive.png"))
    AS_TabMenuAdvanced1.AddTab("Parking",xui.LoadBitmap(File.DirAssets,"parking_active.png"),xui.LoadBitmap(File.DirAssets,"parking_inactive.png"))
    AS_TabMenuAdvanced1.AddTab("Maps",xui.LoadBitmap(File.DirAssets,"maps_active.png"),xui.LoadBitmap(File.DirAssets,"maps_inactive.png"))...

Alexander Stolte

Expert
Licensed User
Longtime User
I recently updated the library
Yes, I have extended the set index property so that you do not have to use ".Refresh" to change the index.

But this property call is also useless because it sets the index to 0 by default when creating the view.

Why it crashes in your project is as follows:
You do this:
B4X:
    AS_TabMenuAdvanced1.AddTab("",xui.LoadBitmap(File.DirAssets,"home_active.png"),xui.LoadBitmap(File.DirAssets,"home_inactive.png"))
    AS_TabMenuAdvanced1.AddTab("Parking",xui.LoadBitmap(File.DirAssets,"parking_active.png"),xui.LoadBitmap(File.DirAssets,"parking_inactive.png"))
    AS_TabMenuAdvanced1.AddTab("Maps",xui.LoadBitmap(File.DirAssets,"maps_active.png"),xui.LoadBitmap(File.DirAssets,"maps_inactive.png"))
    AS_TabMenuAdvanced1.AddTab("Maps",xui.LoadBitmap(File.DirAssets,"maps_active.png"),xui.LoadBitmap(File.DirAssets,"maps_inactive.png"))
    AS_TabMenuAdvanced1.AddTab("Maps",xui.LoadBitmap(File.DirAssets,"maps_active.png"),xui.LoadBitmap(File.DirAssets,"maps_inactive.png"))
    'Where is the "".Refresh" ?
    Sleep(3000)
    
    'Comment out this two lines and it works fine
    AS_TabMenuAdvanced1.Index = 0

If you add tabs, you need to add a ".refresh" before you change the index.
 
Upvote 1
Solution

mcqueccu

Well-Known Member
Licensed User
Longtime User
Yes, I have extended the set index property so that you do not have to use ".Refresh" to change the index.

If you add tabs, you need to add a ".refresh" before you change the index.

Okay. good to know. First I dont need to add refresh after Adding tabs.

But this property call is also useless because it sets the index to 0 by default when creating the view.

I was playing with the indexes to see if the error was from there and left it on 0.
The main app loads the Chooses the index based on what the user previously selected in B4XPages_Appear
 
Upvote 0

Alexander Stolte

Expert
Licensed User
Longtime User
Okay. good to know. First I dont need to add refresh after Adding tabs.
I didn't know that it would be a problem if I made this change. It is also written again in the proeprty description when you hover over it with the mouse. But who reads that :D

The main app loads the Chooses the index based on what the user previously selected in B4XPages_Appear
Good, now you know that you have to do a .refresh after the tabs have been added :)
 
Upvote 0

mcqueccu

Well-Known Member
Licensed User
Longtime User
I did, I saw it and it helped me.
First I call refresh after changing the index, but because of that description, you can see in the sample project I commented the refresh ? out.

Just that I did not send the refresh up to after the AddTabs.

Thanks, you are awesome
 
Upvote 0
Top