#Region Module Attributes
#FullScreen: False
#IncludeTitle: True
#ApplicationLabel: Preise
#VersionCode: 1
#VersionName:
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region
'Activity module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim phone1 As Phone
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 z As String
Dim Top As Int
Dim List1 As List
Dim Listview1 As Table
Dim Edit1 As EditText
Dim Button1, Button2, Button3 As Button
' Definitionen für das Layout
Dim LButton1, Fertig As Button
Dim Label1, Label2, Label3, Label4, Label5 As Label
Dim LEdit1, LEdit2, LEdit3, LEdit4, LEdit5 As EditText
End Sub
Sub Activity_Create(FirstTime As Boolean)
ReadList
Button1.Initialize("Button1")
Button2.Initialize("Button2")
Button3.Initialize("Button3")
Button1.Text = "Suche"
Button2.Text = "Ende"
Button3.Text = "Liste laden"
Edit1.Initialize("Edit1")
Activity.AddView(Button1, 10dip, 10dip, 60dip, 40dip)
Activity.AddView(Edit1, 80dip,10dip, 180dip, 40dip)
Activity.AddView(Button2, 10dip,60dip, 60dip, 40dip)
Activity.AddView(Button3, 80dip, 60dip, 60dip, 40dip)
Listview1.Initialize(Me, "Listview1", 5,Gravity.LEFT, True)
Top = Button2.Top + Button2.Height + 10dip
Listview1.AddToActivity(Activity, 0, Top, 100%x, 100%y) ' Listview unter letzten Button
Listview1.SetHeader(Array As String("WG", "ARTNR", "NAME", "EINH", "PREIS"))
If Activity.width > Activity.height Then
'landscape
Listview1.ClearAll
Listview1.LoadTableFromCSV2(File.DirAssets, "Preise.csv", True, ",", True)
Else
'portrait
Listview1.ClearAll
Listview1.LoadTableFromCSV2(File.DirAssets, "Preise.csv", True, ",", True)
End If
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub ReadList
If File.Exists(File.DirAssets, "Preise.csv") Then
List1 = File.ReadList(File.DirAssets, "Preise.csv")
Else
Msgbox("Kann Datei nicht laden !", "Fehler !")
End If
End Sub
Sub Button1_Click
Dim Liste As List
Dim such As String
Dim zeile As String
Dim str1() As String
Dim gefunden As Int
Liste.Initialize
gefunden = 0
such = Edit1.Text
such = such.ToUpperCase
Liste.Add("WG,ARTNR,NAME,EINH,PREIS")
For i = 1 To List1.Size - 1
zeile = List1.Get(i)
If zeile.IndexOf(such) <> -1 Then
gefunden = gefunden + 1
Liste.Add(zeile)
End If
Next
If gefunden > 0 Then
File.WriteList(File.DirInternalCache, "such.csv", Liste)
Listview1.ClearAll
Listview1.SetHeader(Array As String("WG", "ARTNR", "NAME", "EINH", "PREIS"))
Listview1.LoadTableFromCSV2(File.DirInternalCache, "such.csv", True, ",", True)
Else
Msgbox("Keine Einträge gefunden !", "Info")
End If
phone1.HideKeyboard(Activity)
End Sub
Sub Button3_Click
Listview1.ClearAll
Listview1.LoadTableFromCSV2(File.DirAssets, "Preise.csv", True, ",", True)
End Sub
Sub Fertig_Click
' Daten übernehmen und Layout entfernen
End Sub
Sub Listview1_CellClick(Col As Int, Row As Int)
Msgbox(Listview1.GetValue(1, Row) & "," & Listview1.GetValue(2, Row) &"," & Listview1.GetValue(4, Row), "Gewählt :")
End Sub
Sub Listview1_Cell_LongClick
' Hier das Layout laden
'Activity.LoadLayout("Fenster2")
End Sub
Sub Button2_Click
phone1.SetScreenOrientation(1)
Activity.Finish
End Sub