Spanish Por cada registros (json ) crear un panel tipo facebook [Solucionado]

ebqlabs

Active Member
Licensed User
Hola

Estoy creando una consulta en json que funciona, pero, me gustaría realizar que por cada registro que se realiza, el panel se le de un index o que el label se le de un index. Tipo facebook


B4X:
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

    Dim container As Panel
  
    Dim panel As Panel
  
    Dim col2 As Int = Colors.RGB(231,227,231)
    Dim lblAngle As Int = 5
    Dim border As ColorDrawable
  
    Dim txtpedido As Label
  
    Dim h As HttpJob
    Dim json As JSONParser
  
    Dim pedido As Label
    Dim pedidoxd As Label
End Sub

Sub Activity_Create(FirstTime As Boolean)
    container.Initialize("container")
    Activity.AddView(container,0,0,100%x,100%y)      
    container.Color = Colors.RGB(0,48,107)
    border.Initialize(col2, lblAngle)
  
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''INI SERVICIOS
                                                                                        pedido.Initialize("pedido")
                                                                                        txtpedido.Initialize("txtpedido")

  
  
    panel.Initialize("panel")
    Activity.AddView(panel, 0, 10%y, 100%x, 100%y)
    panel.Color = Colors.RGB (231,227,231)
    panel.Background = border
  
    panel.AddView(pedido, 0, 1%y, 20%x, 7%y)
    pedido.TextSize = 14
    pedido.TextColor = Colors.RGB (0,0,0)

    h.initialize("json", Me)
    h.Download2("direccion http"))
  
End Sub

Sub Activity_Resume
  
End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub JobDone(job As HttpJob)
    If job.Success Then
        json.Initialize(job.GetString)
        CargarDatos
    Else
        Msgbox(job.ErrorMessage, "Error")
    End If
End Sub

Sub CargarDatos
    Dim m As Map
    m=json.NextObject  
    Dim data As List
  
    data=m.Get("data")
  
        For i=0 To data.Size-1
            m=data.Get(i)
          
            pedidoxd.Initialize("pedidoxd")
            Dim row As Int
          
            row = i * 40
          
            panel.AddView(pedidoxd, 0, 1%y + row, 100%x, 80%y)
            pedidoxd.Text = (m.Get("tmp_nom_pac"))
          
        Next
End Sub

Saludos, soy nuevo en b4a.
 

rscheel

Well-Known Member
Licensed User
Longtime User
Tendías que ocupar librerías de material design, ya que lo que quieres es hacer programación en capas y eso es material design.
 

ebqlabs

Active Member
Licensed User
No pude hacer funcionar. Para ser un poco mas claro.

Crear un Label

Realizar un for hasta 10

Label(1)
.
.
.
Label(10)

-------------------------

Crear un evento click para el label

al pinchar un label me diga cual estoy presionando
si Label (2) o Label (5)

Si me podrían ayudar, gracias. Saludos
 

eurojam

Well-Known Member
Licensed User
Longtime User
tienes que hacer algo como eso:
B4X:
Sub label1_click
    Dim label1
    label1 = Sender
End Sub
en el click event paro los labels 1 hasta 10 el sender dice en que label se ha hecho clic
 

ebqlabs

Active Member
Licensed User
Correcto. Con el sender me funciono

Y a su vez pude mandar la información de un label a otro formulario

Gracias.......


Esta solucionado. Gracias ...
 
Last edited:

eurojam

Well-Known Member
Licensed User
Longtime User
Mira:
B4X:
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

    Dim lb(10) As Label
   

End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    'Activity.LoadLayout("Layout1")
   
    For i = 0 To 9
        lb(i).Initialize("lb")
        Activity.AddView(lb(i),  20dip, 20dip + ( 30dip * i), 100dip,20dip)
        lb(i).TextSize=18
        lb(i).Tag = i
        lb(i).Text=i
    Next

End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub lb_click
    Dim label1 As Label
    label1 = Sender
    Log(label1.tag)
End Sub

saludos
stefan
 
Top