#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Private xui As XUI
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 CLV1 As CustomListView
Private Lbl_descripcion As Label
Private CheckBox1 As CheckBox
Private BtnClear As Button
Private ImageView1 As ImageView
Dim Registro As Cursor
Dim SQL1 As SQL
Dim L_denominacion As String
Dim L_id_articulo As String
Dim L_Unitario As Double
Dim L_Imagen As String
Private Lbl_Articulo 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("Custom_articulos")
Activity.Title = "Lista de Productos"
Dim images As List
images.Initialize
'Log(File.DirAssets & " - " & File.DirInternal)
If File.Exists(File.DirRootExternal,"pedidos_tc.db") = False Then
' Ponemos una base inicial de datos en la carpeta Files.
' Luego la copiamos a la SD Card
File.Copy(File.DirInternal,"pedidos_tc.db",File.DirRootExternal,"pedidos_tc.db")
End If
If SQL1.IsInitialized = False Then
SQL1.Initialize(File.DirRootExternal, "pedidos_tc.db", False)
End If
'Log("Carga la tabla usuarios de la basedatos.sql")
Registro = SQL1.ExecQuery("SELECT id_articulo, denominacion, unitario, imagen from articulo limit 200")
For n = 0 To Registro.RowCount - 1
Registro.Position = n
L_denominacion = Registro.GetString("denominacion")
L_id_articulo = Registro.GetString("id_articulo")
L_Unitario = Registro.GetDouble("unitario")
L_Imagen = Registro.GetString("imagen")
CLV1.Add(CreateItem(L_denominacion.Trim, L_Unitario, L_id_articulo, L_Imagen, CLV1.AsView.Width, 50dip), n)
Next
End Sub
Private Sub CreateItem(Text As String, Importe As Double, Articulo As String, Imagen As String, width As Int,height As Int) As B4XView
Dim p As B4XView=xui.CreatePanel("")
p.SetLayoutAnimated(0,0,0,100%x,20%x)
p.LoadLayout("ItemsLayout")
p.Color=Colors.Blue
Dim lbl As Label
lbl.Initialize("")
lbl.Text = Text
Dim lbl1 As Label
lbl1.Initialize("")
lbl1.Text = Importe
lbl1.TextColor = Colors.Yellow
lbl1.TextSize = 20
Dim lbl2 As Label
lbl2.Initialize("")
lbl2.Text = Articulo
lbl2.Visible = False
p.AddView(lbl,75dip, 2dip, 200dip, height - 4dip)
p.AddView(lbl1,175dip, 44dip, 200dip, height - 4dip)
p.AddView(lbl2,175dip, 44dip, 200dip, height - 4dip)
Return p
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub BtnClear_Click
Dim b As Button
b = Sender
b.Text = " hago click"
Log(b.Tag)