Sub Process_Globals
Dim lstText As List
Dim SelectedItem As Int : SelectedItem = -1
End Sub
Sub Globals
Dim edtText As EditText
Dim ltvTexts As ListView
Dim btnSubmit, btnDelete As Button
Dim pnlmenu As Panel
Dim dd As DateDialog
Dim datespin As Spinner
Dim datestr As String
Dim edittext1 As EditText
Dim SelectedDateInTicks As Long
Dim dow As Int
Dim downame As String
Dim datenow As String
Dim now As Long
Dim dddate As String
Dim btndate As Button
End Sub
Sub Activity_Create(FirstTime As Boolean)
Dim i As Int
Activity.LoadLayout("main2.bal")
ltvTexts.ScrollingBackgroundColor = Colors.Transparent
ltvTexts.Color = Colors.Transparent
ltvTexts.Width = 100%x
pnlmenu.Initialize ("")
pnlmenu.Color = Colors.Transparent
ltvTexts.ScrollingBackgroundColor = Colors.Transparent
ltvTexts.SingleLineLayout.Label.TextColor = Colors.Black
ltvTexts.SingleLineLayout.ItemHeight = 100dip
ltvTexts.SingleLineLayout.Label.Height = 100dip
'education-notepad-page.png.Width = 100%x education-notepad-page.png.Height = 100%y
' File.Delete(File.DirInternal, "Text.txt") ' just for testing
If FirstTime = True Then
If File.Exists(File.DirInternal, "Text.txt") = True Then
lstText = File.ReadList(File.DirInternal, "Text.txt")
Else
lstText.Initialize
End If
End If
FillListView
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
File.WriteList(File.DirInternal, "Text.txt", lstText)
End Sub
Sub btnSubmit_Click
If edtText.Text <> "" Then
lstText.InsertAt(0, edtText.Text)
FillListView
edtText.Text = ""
Else
Msgbox("No entry !", "ERROR")
End If
End Sub
Sub FillListView
ltvTexts.Clear
For i = 0 To lstText.Size - 1
ltvTexts.AddSingleLine(lstText.Get(i))
Next
End Sub
Sub btnDelete_Click
Dim Answ As Int
If SelectedItem > -1 Then
Answ = Msgbox2("Do you really want to delete " & lstText.Get(SelectedItem) & " ?", "Delete", "Yes", "", "No", Null)
If Answ = DialogResponse.POSITIVE Then
lstText.RemoveAt(SelectedItem)
ltvTexts.RemoveAt(SelectedItem)
SelectedItem = -1
btnDelete.Visible = False
End If
Else
Msgbox("No item selected !", "ERROR")
End If
End Sub
Sub ltvTexts_ItemClick (Position As Int, Value As Object)
SelectedItem = Position
btnDelete.Visible = True
End Sub
'Sub ltvTexts
'ltvTexts.TextSize = 20
'ltvTexts.TextColor = Colors.Green
'End Sub
Sub Button1_Click
Activity.LoadLayout("Main.bal")
End Sub
Sub btnDate_Click
'Date dialog code
Dim dd As DateDialog
' set the date shown when the dialog is openend
SelectedDateInTicks = DateTime.now
dd.DateTicks = SelectedDateInTicks
'Dd.DateTicks = btnDate.Text
ret = dd.Show("Today's date: " & DateTime.Date(dd.DateTicks), "Date-Chooser", "OK", "Cancel", "", Null)
If ret = DialogResponse.CANCEL Then Return
dow = DateTime.GetDayOfWeek(dd.DateTicks)
dddate = DateTime.Date(dd.DateTicks)
dayofweek
edtText.Text = edtText.Text & " - " & DateTime.date(dd.DateTicks)
End Sub
Sub dayofweek
Select dow
Case 1
downame = "Sun"
Case 2
downame = "Mon"
Case 3
downame = "Tue"
Case 4
downame = "Wed"
Case 5
downame = "Thu"
Case 6
downame = "Fri"
Case 7
downame = "Sat"
End Select
End Sub
Sub GetTicksFromDialog(td As TimeDialog) As Long
Return DateTime.TimeParse(NumberFormat(td.Hour, 2, 0) & ":" & NumberFormat(td.Minute, 2, 0) _
& ":00")
End Sub