Helo,
how getting the Text of selected Listview-Item?
grüße aus Berlin
sinan
how getting the Text of selected Listview-Item?
grüße aus Berlin
sinan
'Activity module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
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 details, cName, cphone As String
Dim listOfContacts As List
Dim lvphone As ListView
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("main")
getcontacts
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub getcontacts
Dim Contacts2 As Contacts2
listOfContacts.Initialize
listOfContacts = Contacts2.GetAll(True,False)
'Log(listOfContacts)
'listOfContacts.Sort(True)
'Log(listOfContacts)
For i = 0 To listOfContacts.Size - 1
Dim Contact As Contact
Contact = listOfContacts.Get(i)
'Log(Contact) 'will print the fields to the LogCat
If Contact.PhoneNumber <>"" Then
'If there Is a Contact number pass it To the ListView so you can see it
'lvphone.TwoLinesLayout.SecondLabel.textcolor=Colors.blue
lvphone.SingleLineLayout.Label.TextSize = 20
lvphone.SingleLineLayout.ItemHeight = 70
lvphone.AddSingleLine(Contact.DisplayName &CRLF &Contact.PhoneNumber)
'lvphone.AddTwoLines(Contact.DisplayName,Contact.PhoneNumber)
lvphone.ScrollingBackgroundColor =Colors.DarkGray
End If
Next
End Sub
Sub lvphone_ItemClick (Position As Int, Value As Object) As String
details = Value
'Log("******************************************")
'Log("selected " & details) 'the name in the logs As a check
'Log("Break found at " & details.IndexOf(CRLF))
'Log("******************************************")
cName=details.SubString2(0,details.IndexOf(CRLF))
Log("Name selected -" & cName & "-")
cphone=details.SubString2(details.IndexOf(CRLF)+1,details.Length)
Log("Phone number -" & cphone & "-")
Activity.Title=cName & "-" & cphone
Return details
End Sub
'listOfContacts.Sort(True)
Dim MyList As List
MyList.Initialize
For i = 0 To listOfContacts.Size -1
MyList.Add(listOfContacts.GetItem(i))
Next
MyList.Sort(True)
listOfContacts.Clear
For i = 0 To MyList.Size -1
listOfContacts.AddSingleLine(MyList.Get(i))
Next
MyList.Sort(True)
java.lang.ClassCastException: java.lang.String cannot be cast to java.util.List
Sub Globals
Dim listOfContacts As ListView
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("main")
listOfContacts.AddSingleLine("Paul")
listOfContacts.AddSingleLine("John")
listOfContacts.AddSingleLine("Abe")
listOfContacts.AddSingleLine("Zino")
Dim MyList As List
MyList.Initialize
For i = 0 To listOfContacts.Size -1
MyList.Add(listOfContacts.GetItem(i))
Next
MyList.Sort(True)
listOfContacts.Clear
For i = 0 To MyList.Size -1
listOfContacts.AddSingleLine(MyList.Get(i))
Next
End Sub
Sub getcontacts
Dim Contact As Contact
Dim Contacts2 As Contacts2
Dim liste As List
liste.Initialize
liste = Contacts2.GetAll(True,False)
Dim MyList As List
MyList.Initialize
For i = 0 To liste.Size -1
MyList.Add(liste.Get(i))
Next
MyList.Sort(True)
ListView1.Clear
For i = 0 To MyList.Size -1
ListView1.AddTwoLines(MyList.Get(i),"")
ListView1.TwoLinesLayout.ItemHeight = 55dip
ListView1.ScrollingBackgroundColor = Colors.Transparent
ListView1.FastScrollEnabled = True
ListView1.TwoLinesLayout.Label.Typeface = Typeface.DEFAULT_BOLD
ListView1.TwoLinesLayout.Label.TextSize = 20
ListView1.TwoLinesLayout.Label.TextColor = Colors.Black
ListView1.TwoLinesLayout.SecondLabel.TextSize = 13
ListView1.TwoLinesLayout.SecondLabel.TextColor=Colors.DarkGray
ListView1.Color=Colors.RGB(255,255,255)
ListView1.TwoLinesLayout.Label.Gravity = Gravity.LEFT
Next
End Sub
This is on presumption ListView is SingLine as in above example.
liste.Sort(True)