Hello to all,
the last thing I developed was the code of a dynamic list of labels with which i replaced 2 of the lists view in my program RemMe.
The utility has been to simplify a part of my code while the performance remained unchanged.
Now what I present to you (it is just an initial idea) is the code for a dynamic list that can be edited.
In this case the list should be usable both as output (showing the contents of a record, for example) while used as input would change the same record directly from the list.
The code you find here works more or less as desired but is still quite fragile and dependent on fixed parameters.
The code is particularly difficult to stabilize because it tied in each phase, to the number of "Views", standard or not, shown in the Activity.
To circumvent part of the problem I have also created a dinamic Edit Text that disappears when aligned with the behavior of the list and simplifies partially the matter.
Unfortunately for this type of Edit Text i was unable to get a correct handling of the text which, while working, it is not particularly pleasant to see/use. (now solved)
This is the actual BETA code
Start/
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim IME As IME
Dim EditText As EditText
Dim Label1 As Label
Dim Label2 As Label
Dim Label3 As Label
Dim Label4 As Label
Dim LG As Label
Dim LVno As Label
Dim Lista, Nlist, Riga As String
Dim Tx As Int
Dim Labels(5,5)
Dim Cambio As String
Dim Dati As String
Dim KT, KL As Int
Dim qq As Int
Dim p as Panel
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")
Activity.LoadLayout("main")
Dati = "Name,Number,Owner,Issued on,Issued by," 'Scadenza,Rinnovato,Note,-,-,"
Crealist
CreaEdit
qq = Activity.NumberOfViews : LVno.Text= LVno.Text & CRLF & qq
End Sub
Sub Label4_Click
'qq = Activity.NumberOfViews : LVno.Text= LVno.Text & CRLF & qq
Crealist
CreaEdit
qq = Activity.NumberOfViews : LVno.Text= LVno.Text & CRLF & qq
End Sub
Sub Label3_Click
'qq = Activity.NumberOfViews : LVno.Text= LVno.Text & CRLF & qq
ClearList
qq = Activity.NumberOfViews : LVno.Text= LVno.Text & CRLF & qq
End Sub
Sub Label1_Click
Activity.Finish
End Sub
Sub EditText_EnterPressed
Riga = Dati.Replace(Cambio, EditText.Text)
Dati = Riga
Label2.Text = Riga
EditText.Text = ""
EditText.Top = 50
EditText.Left = 10
EditText.Visible = False
'qq = Activity.NumberOfViews : LVno.Text= LVno.Text & CRLF & qq
Crealist
qq = Activity.NumberOfViews : LVno.Text= LVno.Text & CRLF & qq
IME.HideKeyboard
End Sub
Sub Label_Click
Dim L As Label
L.Initialize("Label")
L = Sender
Label2.Text = L.Text
End Sub
Sub Crealist
For x = 0 To 4
Lista = Dati
For y = 0 To 4
Dim L As Label
L.Initialize("Label")
L.Visible = True
L.Color = Colors.White
L.TextSize = LG.TextSize
L.TextColor = Colors.Black
L.SendToBack
Activity.AddView(L,10dip ,P.top + y * (LG.Height + 1dip),LG.Width,LG.Height)
'Activity.AddView(L,10dip ,100dip + y * (24dip + 1dip),150dip,24dip)
L.Gravity = Gravity.CENTER_VERTICAL
Tx = (Lista).IndexOf(",")
LG.Text = Lista.SubString2(0, Tx)
Nlist = Lista.SubString2(Tx+1, Lista.Length) '(remaining Lista string)
Lista = Nlist
Labels(x, y) = L
L.Text = LG.Text
Next
Next
qq = Activity.NumberOfViews : LVno.Text= LVno.Text & CRLF & qq
End Sub
Sub ClearList
For m = qq-1 To 7 Step -1
Dim L As Label
L.Initialize("Label")
Activity.RemoveViewAt(m)
Next
qq = Activity.NumberOfViews : LVno.Text= LVno.Text & CRLF & qq
End Sub
Sub Label_LongClick
Cambio = ""
Dim L As Label
L.Initialize("Label")
L = Sender
Cambio = L.Text
'qq = Activity.NumberOfViews : LVno.Text= LVno.Text & CRLF & qq
KT = L.Top
KL = L.Left
EditText.Top = KT 'L.Top
EditText.Left = KL 'L.Left
EditText.Visible = True
EditText.BringToFront
qq = Activity.NumberOfViews : LVno.Text= LVno.Text & CRLF & qq
IME.ShowKeyboard(EditText)
End Sub
Sub CreaEdit
Dim E As EditText
E.Initialize("EditText")
E.Visible = True
E.Color = Colors.White
E.TextSize = LG.TextSize - 3
E.TextColor = Colors.Black
E.SingleLine = True
'E.Gravity = Gravity.CENTER
'E.Typeface = Typeface.DEFAULT_BOLD
E.SendToBack
E.ForceDoneButton = True
Activity.AddView(E,10dip ,50dip * (LG.Height + 1dip),LG.Width,LG.Height)
'Activity.AddView(L,10dip ,50dip + y * (24dip + 1dip),150dip,24dip)
E.Gravity = Gravity.CENTER_VERTICAL
EditText = E
End Sub
End/Code
This string qq = Activity.NumberOfViews : LVno.Text= LVno.Text & CRLF & qq is only a control string
In a nutshell a Click on an item in the list reproduces its value, (as examples into a label) or can start an action.
Instead using a Long Click the Edit Text emulated overlays the label chosen, starts the keyboard and, inserted the text, when you press Enter or Done loads the new text in the list, closing the keyboard itself.
The special feature is that you can edit the list, cancel it dynamically (CLEAR) and then reCREATE it (with the changes already introduced) and to continue the change if necessary.
Obviously if the amended text will be saved when you close the program (not covered by the example), the list will be reloaded with any changes made.
There is still much work to do.....
the last thing I developed was the code of a dynamic list of labels with which i replaced 2 of the lists view in my program RemMe.
The utility has been to simplify a part of my code while the performance remained unchanged.
Now what I present to you (it is just an initial idea) is the code for a dynamic list that can be edited.
In this case the list should be usable both as output (showing the contents of a record, for example) while used as input would change the same record directly from the list.
The code you find here works more or less as desired but is still quite fragile and dependent on fixed parameters.
The code is particularly difficult to stabilize because it tied in each phase, to the number of "Views", standard or not, shown in the Activity.
To circumvent part of the problem I have also created a dinamic Edit Text that disappears when aligned with the behavior of the list and simplifies partially the matter.
Unfortunately for this type of Edit Text i was unable to get a correct handling of the text which, while working, it is not particularly pleasant to see/use. (now solved)
This is the actual BETA code
Start/
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim IME As IME
Dim EditText As EditText
Dim Label1 As Label
Dim Label2 As Label
Dim Label3 As Label
Dim Label4 As Label
Dim LG As Label
Dim LVno As Label
Dim Lista, Nlist, Riga As String
Dim Tx As Int
Dim Labels(5,5)
Dim Cambio As String
Dim Dati As String
Dim KT, KL As Int
Dim qq As Int
Dim p as Panel
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")
Activity.LoadLayout("main")
Dati = "Name,Number,Owner,Issued on,Issued by," 'Scadenza,Rinnovato,Note,-,-,"
Crealist
CreaEdit
qq = Activity.NumberOfViews : LVno.Text= LVno.Text & CRLF & qq
End Sub
Sub Label4_Click
'qq = Activity.NumberOfViews : LVno.Text= LVno.Text & CRLF & qq
Crealist
CreaEdit
qq = Activity.NumberOfViews : LVno.Text= LVno.Text & CRLF & qq
End Sub
Sub Label3_Click
'qq = Activity.NumberOfViews : LVno.Text= LVno.Text & CRLF & qq
ClearList
qq = Activity.NumberOfViews : LVno.Text= LVno.Text & CRLF & qq
End Sub
Sub Label1_Click
Activity.Finish
End Sub
Sub EditText_EnterPressed
Riga = Dati.Replace(Cambio, EditText.Text)
Dati = Riga
Label2.Text = Riga
EditText.Text = ""
EditText.Top = 50
EditText.Left = 10
EditText.Visible = False
'qq = Activity.NumberOfViews : LVno.Text= LVno.Text & CRLF & qq
Crealist
qq = Activity.NumberOfViews : LVno.Text= LVno.Text & CRLF & qq
IME.HideKeyboard
End Sub
Sub Label_Click
Dim L As Label
L.Initialize("Label")
L = Sender
Label2.Text = L.Text
End Sub
Sub Crealist
For x = 0 To 4
Lista = Dati
For y = 0 To 4
Dim L As Label
L.Initialize("Label")
L.Visible = True
L.Color = Colors.White
L.TextSize = LG.TextSize
L.TextColor = Colors.Black
L.SendToBack
Activity.AddView(L,10dip ,P.top + y * (LG.Height + 1dip),LG.Width,LG.Height)
'Activity.AddView(L,10dip ,100dip + y * (24dip + 1dip),150dip,24dip)
L.Gravity = Gravity.CENTER_VERTICAL
Tx = (Lista).IndexOf(",")
LG.Text = Lista.SubString2(0, Tx)
Nlist = Lista.SubString2(Tx+1, Lista.Length) '(remaining Lista string)
Lista = Nlist
Labels(x, y) = L
L.Text = LG.Text
Next
Next
qq = Activity.NumberOfViews : LVno.Text= LVno.Text & CRLF & qq
End Sub
Sub ClearList
For m = qq-1 To 7 Step -1
Dim L As Label
L.Initialize("Label")
Activity.RemoveViewAt(m)
Next
qq = Activity.NumberOfViews : LVno.Text= LVno.Text & CRLF & qq
End Sub
Sub Label_LongClick
Cambio = ""
Dim L As Label
L.Initialize("Label")
L = Sender
Cambio = L.Text
'qq = Activity.NumberOfViews : LVno.Text= LVno.Text & CRLF & qq
KT = L.Top
KL = L.Left
EditText.Top = KT 'L.Top
EditText.Left = KL 'L.Left
EditText.Visible = True
EditText.BringToFront
qq = Activity.NumberOfViews : LVno.Text= LVno.Text & CRLF & qq
IME.ShowKeyboard(EditText)
End Sub
Sub CreaEdit
Dim E As EditText
E.Initialize("EditText")
E.Visible = True
E.Color = Colors.White
E.TextSize = LG.TextSize - 3
E.TextColor = Colors.Black
E.SingleLine = True
'E.Gravity = Gravity.CENTER
'E.Typeface = Typeface.DEFAULT_BOLD
E.SendToBack
E.ForceDoneButton = True
Activity.AddView(E,10dip ,50dip * (LG.Height + 1dip),LG.Width,LG.Height)
'Activity.AddView(L,10dip ,50dip + y * (24dip + 1dip),150dip,24dip)
E.Gravity = Gravity.CENTER_VERTICAL
EditText = E
End Sub
End/Code
This string qq = Activity.NumberOfViews : LVno.Text= LVno.Text & CRLF & qq is only a control string
In a nutshell a Click on an item in the list reproduces its value, (as examples into a label) or can start an action.
Instead using a Long Click the Edit Text emulated overlays the label chosen, starts the keyboard and, inserted the text, when you press Enter or Done loads the new text in the list, closing the keyboard itself.
The special feature is that you can edit the list, cancel it dynamically (CLEAR) and then reCREATE it (with the changes already introduced) and to continue the change if necessary.
Obviously if the amended text will be saved when you close the program (not covered by the example), the list will be reloaded with any changes made.
There is still much work to do.....
Attachments
Last edited: