Android Question Set recursive view customlistview at runtime

rkxo

Active Member
Licensed User
hi,
I want set a customlistview in runtime is possible?

B4X:
                    Dim pnl As Panel = InfoAveriesListViewNova.GetPanel(6) 'customlistview Verical Mode
                    Dim horpan As CustomListviewNewBas=pnl.GetView(5) 'index 5 = customlistview Horizontal mode
                    Dim d As Panel
                    d.Initialize("")
                    d.LoadLayout("fotoload") ' load imageview into panel
                    d.Width=PanImageDown.Width
                    ImageDown.Tag=1
                    horpan.Add(d,Null) -->crash here ' add imageview into customlistview horizontal

But get this error

B4X:
** Activity (main) Pause, UserClosed = false **
** Service (cargafotop) Start **
sending message to waiting queue (OnActivityResult)
running waiting messages (1)
Original:17060
Comprimida:1984
Panel size is unknown. Layout may not be loaded correctly.
Error occurred on line: 6152 (Main)
java.lang.RuntimeException: Field: ba not found in: anywheresoftware.b4a.BALayout
    at anywheresoftware.b4a.shell.Shell$FieldCache.getField(Shell.java:923)
    at anywheresoftware.b4a.shell.Shell.getField(Shell.java:697)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:360)
    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.raiseEvent2(BA.java:180)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
    at net.garstangs.ezcamera.EZcamera$1.ResultArrived(EZcamera.java:59)
    at anywheresoftware.b4a.BA$4.run(BA.java:568)
    at anywheresoftware.b4a.BA.setActivityPaused(BA.java:442)
    at aluvisa.gestv2.com.main$ResumeMessage.run(main.java:306)
    at android.os.Handler.handleCallback(Handler.java:751)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6077)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
Any idea?

Thanks
 
Last edited:

Myr0n

Active Member
Licensed User
Can you post your question in the appropriate forum please.
 

Erel

Administrator
Staff member
Licensed User
Moved to the questions forum.

Don't ignore this message: Panel size is unknown. Layout may not be loaded correctly.
Call d.SetLayout before loading the layout.

The problem is here:
B4X:
 Dim horpan As CustomListviewNewBas=pnl.GetView(5)
The returned view will never be a custom view.
1. When you create the clv:
B4X:
horpan.AsView.Tag = horpan
2. Get it:
B4X:
Dim horpan As CustomListviewNewBas = pnl.GetView(5).Tag
Combining two scrollable views will be problematic.
 

rkxo

Active Member
Licensed User
sorry, but i understand it.

where i put this code?
B4X:
horpan.AsView.Tag = horpan
becouse horpan is only a temporal clv for get view of real clv horizontal created in designer

example

B4X:
Globals
dim HorizontalCLV as CustomListView ' Mode Horizontal .Added in designer layout named "hor.bal". The index of HorizontalCLV is 1
dim VerticalClv as CustomListView
..
' 1 )Create ClV
sub1()

 
      dim r as panel
      r.loadlayout("hor.bal")
      for i=1 to 5
      VerticalClv.add(r, null)
      next

' 2 )Get Clv
Sub2()
 
      Dim pnl As Panel = VerticalClv.GetPanel(2) 'customlistview Verical Mode
      Dim horpan As CustomListview=pnl.GetView(1).tag ?? 'index 1 = customlistview Horizontal mode

Or i create....


B4X:
Globals
dim HorizontalCLV as CustomListView ' Mode Horizontal .Added in designer layout named "hor.bal". The index of HorizontalCLV is 1
dim VerticalClv as CustomListView

..
' 1 )Create ClV
sub1()


      dim r as panel
      r.loadlayout("hor.bal")
      for i=1 to 5
      VerticalClv.add(r, null)
VerticalClv.asview.tag=VerticalClv
      next

' 2 )Get Clv
Sub2()
 
      Dim pnl As Panel = VerticalClv.GetPanel(2) 'customlistview Verical Mode
      dim horpan as CustomListView=pnl.GetView(1).tag ?? 'index 1 = customlistview Horizontal mode
 
Last edited:

rkxo

Active Member
Licensed User
I found the solution.
When i loadlayout bal file i copy clv in a temporaly clv
and later when i want set i copy temp clv into original bal clv and later set original and works
thanks
 
Top