Android Question CustomListView & Android 9

fishwolf

Well-Known Member
Licensed User
Longtime User
Why i have this error with this code only with Androin 9?

if remove Calendar.Add(CreateListPrivacy(0), 0) work fine

B4X:
Panel size is unknown. Layout may not be loaded correctly.
Panel size is unknown. Layout may not be loaded correctly.
Panel size is unknown. Layout may not be loaded correctly.
Panel size is unknown. Layout may not be loaded correctly.
menu_createlistprivacy (java line: 543)
java.lang.RuntimeException: java.lang.IllegalArgumentException: Cannot set 'scaleX' to Float.NaN
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:170)
    at anywheresoftware.b4a.objects.PanelWrapper.LoadLayout(PanelWrapper.java:134)
    at it.software.castiel.ddfc.menu._createlistprivacy(menu.java:543)
    at it.software.castiel.ddfc.menu._activity_create(menu.java:408)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
    at it.software.castiel.ddfc.menu.afterFirstLayout(menu.java:104)
    at it.software.castiel.ddfc.menu.access$000(menu.java:17)
    at it.software.castiel.ddfc.menu$WaitForLayout.run(menu.java:82)
    at android.os.Handler.handleCallback(Handler.java:873)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:201)
    at android.app.ActivityThread.main(ActivityThread.java:6810)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)
Caused by: java.lang.IllegalArgumentException: Cannot set 'scaleX' to Float.NaN
B4X:
    Calendar.Add(CreateListItem("14", "Settembre", "aaaa", "Street", Calendar.AsView.Width, 80dip), 35)
 
    Calendar.Add(CreateListPrivacy(0), 0)


Sub CreateListPrivacy(Width As Int) As Panel
Dim p As Panel
 
    p.Initialize("")
    p.LoadLayout("privacy_item")
    p.SetLayout(0, 0, 100%x, 40dip)
    Return p
End Sub

Sub CreateListItem(Day As String, Month As String, Club As String, Address As String, Width As Int, Height As Int) As Panel
Dim p As Panel

    p.Initialize("")
    p.LoadLayout("calendar_item")
    p.SetLayout(0, 0, Width, PanelDate.Height)
    LabelDay.Text = Day
    LabelMonth.Text = Month
    LabelClub.Text = Club
    LabelAddress.Text = Address
    Return p
End Sub
 
Last edited:

fishwolf

Well-Known Member
Licensed User
Longtime User
Never load a layout to a zero sized panel.
Correct code:
B4X:
Sub CreateListPrivacy(Width As Int) As Panel
Dim p As Panel
 
    p.Initialize("")
p.SetLayout(0, 0, 100%x, 40dip) '<--- set the size before loading the layout
    p.LoadLayout("privacy_item")
  
    Return p
End Sub

i have moved SetLayout because the item Height setted to 80dip, with android 9 sometimes, is too small

i have replace with the height of panel inside the layout (PanelDate.Height)

how to set the height correctly?
 
Upvote 0

fishwolf

Well-Known Member
Licensed User
Longtime User
There is no such thing. You need to set the height as you need it.
if i set the anchor to expand and height=80dip the border down is out of layout
 

Attachments

  • List1.zip
    52.8 KB · Views: 127
  • Screenshot_2019-07-08-22-01-00.png
    Screenshot_2019-07-08-22-01-00.png
    23.2 KB · Views: 132
Last edited:
Upvote 0
Top