Android Question CustomListView & Android 9

Discussion in 'Android Questions' started by fishwolf, Jul 3, 2019.

  1. fishwolf

    fishwolf Active Member Licensed User

    Why i have this error with this code only with Androin 9?

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

    Code:
    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
    Code:
    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(
    00100%x40dip)
        
    Return p
    End Sub

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

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

    Brandsum Active Member Licensed User

    That happen if you set view anchor to both in designer. So you will not be able get the width of that view in code
     
  3. fishwolf

    fishwolf Active Member Licensed User

    i have the error also if set item_privacy as empty layout and remove autoscale
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    Never load a layout to a zero sized panel.
    Correct code:
    Code:
    Sub CreateListPrivacy(Width As Int) As Panel
    Dim p As Panel
     
        p.Initialize(
    "")
    p.SetLayout(
    00100%x40dip'<--- set the size before loading the layout
        p.LoadLayout("privacy_item")
       
        
    Return p
    End Sub
     
  5. fishwolf

    fishwolf Active Member Licensed User

    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?
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    There is no such thing. You need to set the height as you need it.
     
  7. fishwolf

    fishwolf Active Member Licensed User

    if i set the anchor to expand and height=80dip the border down is out of layout
     

    Attached Files:

    Last edited: Jul 8, 2019
  8. Erel

    Erel Administrator Staff Member Licensed User

    This layout is incorrect:
    [​IMG]

    The distance from the bottom edge is set to 350dip. You have several options to fix it. The simplest one is to anchor the top panel to the top instead of BOTH.
    I also recommend you to remove the AutoScaleAll call for these items as the variant size is different than the real size.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice