Android Question ScrollView - Panel position- Panel data

luisro

Member
Licensed User
Greetings, my question is how to take the data of the position of the panel (value) that is added to a ScrollView when clicking (label, imageview etc)

B4X:
Sub FillScrollView
    Dim Bitmap1 As Bitmap
    Dim Panel0 As Panel
    Dim PanelTop, PanelHeight, Label2Top, ProgressBarTop, ProgressBarWidth As Int
    Dim Progress As Int
  
    Bitmap1.Initialize(File.DirAssets,"Icon.png")
    PanelTop=0
    Panel0=ScrollView1.Panel
    Panel0.Color=Colors.Gray

    For i=0 To 99
        Dim Panel1 As Panel
        Dim ImageView1 As ImageView
        Dim ProgressBar1 As ProgressBar
      
         Panel1.Initialize("")
      
        PanelHeight=99dip
        Label2Top=75dip
        ProgressBarTop=65dip
        ProgressBarWidth=210dip
  
        Panel0.AddView(Panel1,0,PanelTop,ScrollView1.Width,PanelHeight)
        Panel1.Color=Colors.Black
      
        ImageView1.Initialize("")
        Panel1.AddView(ImageView1,5dip,5dip,65dip,65dip)
        ImageView1.Bitmap=Bitmap1
      
      
        Dim Label1, Label2,Label3, Label4, Label5,label6,label7,label8 As Label
        Label1.Initialize("")
        Panel1.AddView(Label1,80dip,5dip,240dip,30dip)
        Label1.Color=Colors.Black
        Label1.Tag="Label1"
        Label1.Text=Text1

        Label2.Initialize("")
        Panel1.AddView(Label2,80dip,Label2Top,240dip,30dip)
        Label2.TextSize=14
        Label2.Tag="Label2"
        Label2.Text=Text2
        Label2.TextSize=15
          
        Label3.Initialize("")
        Panel1.AddView(Label3,80dip,30dip,240dip,30dip)
        Label3.Tag="Label3"
        Label3.Text=Text3
        Label3.TextSize=11

        Label4.Initialize("")
        Panel1.AddView(Label4,10dip,70dip,60dip,30dip)
        Label4.Tag="Label4"
        Label4.Text=Text4
        Label4.TextSize=11
        Label4.Gravity=Gravity.BOTTOM

        Label5.Initialize("")
        Panel1.AddView(Label5,80dip,45dip,240dip,30dip)
        Label5.Tag="Label5"
        Label5.Text="12.000bs"
        Label5.TextColor = Colors.yellow
        Label5.TextSize=11
        Label4.Gravity=Gravity.CENTER
      
  
        PanelTop=PanelTop+PanelHeight+1dip
    Next
    Panel0.Height=PanelTop
End Sub
 

luisro

Member
Licensed User
Any construction tutorials? My need is to make a fixed design that contains an image, some features, some numbers and small icons according to the product. Then load the data from a database to the pre-set design.
 
Upvote 0

luisro

Member
Licensed User
Ok, I already loaded a customlistview through a panel. My only doubt is like every one of the values of the tags and image in the position of the custom listview? Also individualize the image of the list to click to expand
 
Upvote 0

luisro

Member
Licensed User
B4X:
Sub Globals
    Dim clv1 As CustomListView
    Dim p As Panel
    Dim panel2 As Panel

   
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("1")
    actividad
End Sub

Sub actividad

    For i = 1 To 20
        Dim imagen,imagen2,imagen3,imagen4,imagen5,imagen6 As ImageView
        Dim p As Panel
        Dim Bitmap1 As Bitmap
        Dim Bitmap2 As Bitmap
        Dim Bitmap3 As Bitmap
        Dim Bitmap4 As Bitmap
        Dim Bitmap5 As Bitmap
        Dim Bitmap6 As Bitmap
   
        Bitmap1.Initialize(File.DirAssets,"Icon.png")
        Bitmap2.Initialize(File.DirAssets,"fverde.png")
        Bitmap3.Initialize(File.DirAssets,"froja.png")
        Bitmap4.Initialize(File.DirAssets,"iconoleche.png")
        Bitmap5.Initialize(File.DirAssets,"iconoazucar2.png")
        Bitmap6.Initialize(File.DirAssets,"iconoin.png")
        p.Initialize("")
        p.Color = Colors.White
   
        'IMAGEN DEL PRODUCTO    //////////////////////////////////////
        imagen.Initialize("")
        p.AddView(imagen,5dip,5dip,65dip,65dip)
        imagen.Bitmap=Bitmap1
   
        'FLECHAS//////////////////////////////////////////////////////
       
        'VERDE
        imagen2.Initialize("")
        p.AddView(imagen2, 180dip, 55dip, 240dip,50)
        imagen2.Bitmap=Bitmap2
       
        'ROJA
        imagen3.Initialize("")
        p.AddView(imagen3, 180dip, 70dip, 240dip,50)
        imagen3.Bitmap=Bitmap3
       
        'iCONOS LEYENDA////////////////////////////////////////////////
        imagen4.Initialize("")
        p.AddView(imagen4,80dip, 35dip, 240dip, 60)
        imagen4.Gravity =  Bit.Or(Gravity.CENTER_VERTICAL, Gravity.LEFT)
        imagen4.Bitmap=Bitmap4
       
        imagen5.Initialize("")
        p.AddView(imagen5, 100dip, 35dip, 240dip, 60)
        imagen5.Gravity =  Bit.Or(Gravity.CENTER_VERTICAL, Gravity.LEFT)
        imagen5.Bitmap=Bitmap5
       
       
        imagen6.Initialize("")
        p.AddView(imagen6,120dip, 35dip, 240dip, 60)
        imagen6.Gravity =  Bit.Or(Gravity.CENTER_VERTICAL, Gravity.LEFT)
        imagen6.Bitmap=Bitmap6
       
        'LOTE/////////////////////////////////////////////////////////
        Dim lbl6 As Label
        lbl6.Initialize("")
        p.AddView(lbl6, 25dip,45dip,65dip,65dip)
        lbl6.Gravity = Bit.Or(Gravity.CENTER_VERTICAL, Gravity.LEFT)
        lbl6.Tag="Label3"
        lbl6.Text = "07/17"
        lbl6.TextSize = 11
        lbl6.TextColor = Colors.Black
       
        'TITULO/////////////////////////////////////////////////////////
        Dim lbl2 As Label
        lbl2.Initialize("")
        p.AddView(lbl2, 80dip, 5dip, 240dip, 30)
        lbl2.Gravity = Bit.Or(Gravity.CENTER_VERTICAL, Gravity.LEFT)
        lbl2.Tag="Label2"
        lbl2.Text = "Chicha Kiana"
        lbl2.TextSize = 14
        lbl2.TextColor = Colors.Black
   
        'GRAMAJE/////////////////////////////////////////////////////////
        Dim lbl3 As Label
        lbl3.Initialize("")
        p.AddView(lbl3, 80dip, 25dip, 240dip, 30)
        lbl3.Gravity = Bit.Or(Gravity.CENTER_VERTICAL, Gravity.LEFT)
        lbl3.Tag="Label3"
        lbl3.Text = "500"&"Gr"
        lbl3.TextSize = 13
        lbl3.TextColor = 0xFF424242
       
        If (i Mod 2)=0 Then
        'PRECIO//////////////////////////////////////////////////////////
        Dim lbl4 As Label
        lbl4.Initialize("")
        p.AddView(lbl4, 80dip, 65dip, 240dip,30)
        lbl4.Gravity = Bit.Or(Gravity.CENTER_VERTICAL, Gravity.LEFT)
        lbl4.Tag="Label4"
        lbl4.Text = "10.000"&"BS"
        lbl4.TextSize = 13
        lbl4.Typeface = Typeface.DEFAULT_BOLD
        lbl4.TextColor = Colors.Black
        Else
            Dim lbl4 As Label
            lbl4.Initialize("")
            p.AddView(lbl4, 80dip, 65dip, 240dip,30)
            lbl4.Gravity = Bit.Or(Gravity.CENTER_VERTICAL, Gravity.LEFT)
            lbl4.Tag="Label4"
            lbl4.Text = "5.000"&"BS"
            lbl4.TextSize = 13
            lbl4.Typeface = Typeface.DEFAULT_BOLD
            lbl4.TextColor = Colors.Black
        End If
        'DIFERENCIA DE PRECIO////////////////////////////////////////////
        Dim lbl5 As Label
        lbl5.Initialize("")
        p.AddView(lbl5, 255dip, 66dip, 240dip,30)
        lbl5.Gravity = Bit.Or(Gravity.CENTER_VERTICAL, Gravity.LEFT)
        lbl5.Tag="Label4"
        lbl5.Text = "1500"
        lbl5.TextSize = 13
        lbl5.TextColor = Colors.Black
        clv1.Add(p,140,i)
    Next
End Sub


Sub clv1_ItemClick (Index As Int, Value As Object)
   
   
End Sub

It is an example code, with the full code a customlistview (clv1) with a panel (p) previously filled with label and imageview. I just want to make clv1_ItemClick the panel2 that is just above my customlistview is filled with the panel where we click (which is p in the position value of the customlistview). Finally I need to take the values of Panel2 (lbl1, lbl2, lbl3 etc) to perform a mathematical operations.

Is only sample code to build, in future all values will be taken from a database.
 
Upvote 0
Top