How would i create a second text file for another activity. I tried renaming the text file but that didn't seem to work.
Here is the code
Tell me if you need the zip file.
Here is the code
Tell me if you need the zip file.
B4X:
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
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