:sign0089:Hello
I have a scrollview where I show data from a database, in the layout "principal" in the EditText "EDT2" I write a text, then select the I click the "pnlMed" to select what position I want to update the data i finally pulse the "btnSave" layout "main". The data is saved but the ScrollView does not update until I close or minimize the application. As I can make to save the changes to be updated by pressing the "btnSave".
thanks
'Activity module
Sub Process_Globals
'Aquestes variables globals es va declarar una vegada quan s'inicia l'aplicació.
'Aquestes variables es pot accedir des de tots els mòduls.
' Nom DB, ubicació i noms taules
Dim SQLMedicament As SQL
Dim DBFileName As String : DBFileName = "bebepediatra.db"
'Dim DBFileDir As String : DBFileDir = File.DirInternal
'Dim DBFileDir As String : DBFileDir = File.DirRootExternal
Dim DBFileDir As String : DBFileDir = File.DirDefaultExternal
Dim DBTableNameMedicament As String : DBTableNameMedicament = "medicament"
Dim NumberOfColumns As Int : NumberOfColumns = 6 'IMPORTANT NUMERO COLUMNES
Dim NumberOfRows As Int
Dim ColumnName(NumberOfColumns) As String ' noms de les columnes
ColumnName(0) = "ID_med"
ColumnName(1) = "nom_med"
ColumnName(2) = "descripcio_med"
ColumnName(3) = "contraindicacions_med"
ColumnName(4) = "formula_med"
ColumnName(5) = "caducitat_med"
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 scvMed As ScrollView
Dim PanelHeight As Int : PanelHeight = 160dip
Dim PanelHeight_1 As Int : PanelHeight_1 = PanelHeight - 2dip
Dim pnl1Nb As Int : pnl1Nb=5
Dim edt1, edt2 As EditText
Dim panel1 As Panel
Dim ClickedPanel As Panel
Dim pos As Int
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("inicial")
'File.Delete(DBFileDir, DBFileName) ' used for testing, deletes the existing database
' initilize the database IMPORTANT
If File.Exists(DBFileDir, DBFileName) = False Then
If FirstTime Then
File.Copy(File.DirAssets, DBFileName, DBFileDir, DBFileName)
SQLMedicament.Initialize(DBFileDir, DBFileName, True)
End If
Else
If FirstTime Then
SQLMedicament.Initialize(DBFileDir, DBFileName, True)
End If
End If
End Sub
Sub Activity_Resume
' reads the database
NumberOfRows = 0
SQLTableRead
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub AddRow(Values() As String)
'Adds a row to the table
Dim pnlMed As Panel
pnlMed.Initialize("panel1")
pnlMed.LoadLayout("components")
pnlMed.Color = Colors.Black
pnlMed.Tag = NumberOfRows
scvMed.panel.AddView(pnlMed, 0, 5dip + NumberOfRows * PanelHeight, 100%x, PanelHeight_1)
'LEFT TOP WIDTH HEIGHT
Dim lbl1 As Label
' lbl1 is view 0 in the panel
lbl1 = pnlMed.GetView(0)
lbl1.Tag = NumberOfRows
lbl1.TextSize=20
lbl1.Text = Values(1)
Dim lbl2 As Label
' lbl2 is view 2 in the panel
lbl2 = pnlMed.GetView(1)
lbl2.Tag = NumberOfRows
lbl2.TextSize=20
lbl2.Text = Values(2)
'Dim edt1 As EditText
' edt1 is view 1 in the panel
edt1 = pnlMed.GetView(2)
edt1.Tag = NumberOfRows
edt1.Text = Values(2)
NumberOfRows = NumberOfRows + 1
scvMed.panel.Height = NumberOfRows * PanelHeight
End Sub
Sub SQLTableRead
' Reads the SQL data base
Dim i As Int
Dim Cursor1 As Cursor
Dim txt As String
txt = "SELECT * FROM " & DBTableNameMedicament
Cursor1 = SQLMedicament.ExecQuery(txt)
For i = 0 To Cursor1.RowCount - 1
Dim Col(NumberOfColumns) As String
Cursor1.Position = i
For j = 0 To NumberOfColumns - 1
Col(j) = Cursor1.GetString(ColumnName(j))
Next
AddRow(Col)
Next
Cursor1.Close
Activity.Title = "Bebe Pediatra"
End Sub
Sub btnSave_Click
ClickedPanel.Initialize("")
Dim p As Panel
p.Initialize("")
Dim mapa As Map
mapa.Initialize
mapa.Put("nom_med", pos)
DBUtils.UpdateRecord(SQLMedicament, DBTableNameMedicament, "descripcio_med", edt2.Text , mapa)
Activity.Title ="afdfdfdfd "& (pos)
End Sub
Sub Panel1_Click
ClickedPanel=Sender
Activity.Title ="Tag of clicked panel is "& (ClickedPanel.Tag + 1)
pos = (ClickedPanel.tag + 1 )
End Sub
I have a scrollview where I show data from a database, in the layout "principal" in the EditText "EDT2" I write a text, then select the I click the "pnlMed" to select what position I want to update the data i finally pulse the "btnSave" layout "main". The data is saved but the ScrollView does not update until I close or minimize the application. As I can make to save the changes to be updated by pressing the "btnSave".
thanks
'Activity module
Sub Process_Globals
'Aquestes variables globals es va declarar una vegada quan s'inicia l'aplicació.
'Aquestes variables es pot accedir des de tots els mòduls.
' Nom DB, ubicació i noms taules
Dim SQLMedicament As SQL
Dim DBFileName As String : DBFileName = "bebepediatra.db"
'Dim DBFileDir As String : DBFileDir = File.DirInternal
'Dim DBFileDir As String : DBFileDir = File.DirRootExternal
Dim DBFileDir As String : DBFileDir = File.DirDefaultExternal
Dim DBTableNameMedicament As String : DBTableNameMedicament = "medicament"
Dim NumberOfColumns As Int : NumberOfColumns = 6 'IMPORTANT NUMERO COLUMNES
Dim NumberOfRows As Int
Dim ColumnName(NumberOfColumns) As String ' noms de les columnes
ColumnName(0) = "ID_med"
ColumnName(1) = "nom_med"
ColumnName(2) = "descripcio_med"
ColumnName(3) = "contraindicacions_med"
ColumnName(4) = "formula_med"
ColumnName(5) = "caducitat_med"
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 scvMed As ScrollView
Dim PanelHeight As Int : PanelHeight = 160dip
Dim PanelHeight_1 As Int : PanelHeight_1 = PanelHeight - 2dip
Dim pnl1Nb As Int : pnl1Nb=5
Dim edt1, edt2 As EditText
Dim panel1 As Panel
Dim ClickedPanel As Panel
Dim pos As Int
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("inicial")
'File.Delete(DBFileDir, DBFileName) ' used for testing, deletes the existing database
' initilize the database IMPORTANT
If File.Exists(DBFileDir, DBFileName) = False Then
If FirstTime Then
File.Copy(File.DirAssets, DBFileName, DBFileDir, DBFileName)
SQLMedicament.Initialize(DBFileDir, DBFileName, True)
End If
Else
If FirstTime Then
SQLMedicament.Initialize(DBFileDir, DBFileName, True)
End If
End If
End Sub
Sub Activity_Resume
' reads the database
NumberOfRows = 0
SQLTableRead
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub AddRow(Values() As String)
'Adds a row to the table
Dim pnlMed As Panel
pnlMed.Initialize("panel1")
pnlMed.LoadLayout("components")
pnlMed.Color = Colors.Black
pnlMed.Tag = NumberOfRows
scvMed.panel.AddView(pnlMed, 0, 5dip + NumberOfRows * PanelHeight, 100%x, PanelHeight_1)
'LEFT TOP WIDTH HEIGHT
Dim lbl1 As Label
' lbl1 is view 0 in the panel
lbl1 = pnlMed.GetView(0)
lbl1.Tag = NumberOfRows
lbl1.TextSize=20
lbl1.Text = Values(1)
Dim lbl2 As Label
' lbl2 is view 2 in the panel
lbl2 = pnlMed.GetView(1)
lbl2.Tag = NumberOfRows
lbl2.TextSize=20
lbl2.Text = Values(2)
'Dim edt1 As EditText
' edt1 is view 1 in the panel
edt1 = pnlMed.GetView(2)
edt1.Tag = NumberOfRows
edt1.Text = Values(2)
NumberOfRows = NumberOfRows + 1
scvMed.panel.Height = NumberOfRows * PanelHeight
End Sub
Sub SQLTableRead
' Reads the SQL data base
Dim i As Int
Dim Cursor1 As Cursor
Dim txt As String
txt = "SELECT * FROM " & DBTableNameMedicament
Cursor1 = SQLMedicament.ExecQuery(txt)
For i = 0 To Cursor1.RowCount - 1
Dim Col(NumberOfColumns) As String
Cursor1.Position = i
For j = 0 To NumberOfColumns - 1
Col(j) = Cursor1.GetString(ColumnName(j))
Next
AddRow(Col)
Next
Cursor1.Close
Activity.Title = "Bebe Pediatra"
End Sub
Sub btnSave_Click
ClickedPanel.Initialize("")
Dim p As Panel
p.Initialize("")
Dim mapa As Map
mapa.Initialize
mapa.Put("nom_med", pos)
DBUtils.UpdateRecord(SQLMedicament, DBTableNameMedicament, "descripcio_med", edt2.Text , mapa)
Activity.Title ="afdfdfdfd "& (pos)
End Sub
Sub Panel1_Click
ClickedPanel=Sender
Activity.Title ="Tag of clicked panel is "& (ClickedPanel.Tag + 1)
pos = (ClickedPanel.tag + 1 )
End Sub
Last edited: