Don't use ListView.
Use xCustomListView - it is more powerful, easier to work with and cross platform.
Use xCustomListView - it is more powerful, easier to work with and cross platform.
Last edited:
Type MyView(row1 As String, row2 As String)
Sub ListView1_ItemClick (Position As Int, Value As Object)
Dim all As MyView ' Declaring a variable 'all' as the type we created above in Process_Globals
all = Value 'Assigning the value of the clicked item to our variable
End Sub
Dim stt as String = all.row1 'This gets the 1st line in the item and assigns it to a String variable stt
Dim stt2 as String = all.row2 'This gets the 2nd line in the item and assigns it to a String variable stt2
Declare a type in Process_Globals sub of any code or activity module
eg.
B4X:Type MyView(row1 As String, row2 As String)
Then, on the ItemClick event of your listview, you assign the value of the item clicked to a "MyView" variable
eg.
Then, to retrieve one of the two lines in the item, you call any of the following:B4X:Sub ListView1_ItemClick (Position As Int, Value As Object) Dim all As MyView ' Declaring a variable 'all' as the type we created above in Process_Globals all = Value 'Assigning the value of the clicked item to our variable End Sub
I hope this will be of help.B4X:Dim stt as String = all.row1 'This gets the 1st line in the item and assigns it to a String variable stt Dim stt2 as String = all.row2 'This gets the 2nd line in the item and assigns it to a String variable stt2
By color, do you mean the backcolor of each item?how can I change the color property of the list view if you use AddTwoLines2?
thanks
I need to change The text color.
Thanks
'Say lv is your listview (with two lines)
lv.TwoLinesLayout.Label.TextColor = Colors.Gray '1st Line text color
lv.TwoLinesLayout.SecondLabel.TextColor = Colors.Red '2nd Line text color
' There are other properties as you'll realise.
Entering the name of a type, say - lv (being a listview), followed by a period(.) brings up all the properties and methods of that type.OK, but where can I find all members and property of the object? thanks
Declare a type in Process_Globals sub of any code or activity module
eg.
B4X:Type MyView(row1 As String, row2 As String)
Then, on the ItemClick event of your listview, you assign the value of the item clicked to a "MyView" variable
eg.
Then, to retrieve one of the two lines in the item, you call any of the following:B4X:Sub ListView1_ItemClick (Position As Int, Value As Object) Dim all As MyView ' Declaring a variable 'all' as the type we created above in Process_Globals all = Value 'Assigning the value of the clicked item to our variable End Sub
I hope this will be of help.B4X:Dim stt as String = all.row1 'This gets the 1st line in the item and assigns it to a String variable stt Dim stt2 as String = all.row2 'This gets the 2nd line in the item and assigns it to a String variable stt2
Dim all As MyView ' Declaring a variable 'all' as the type we created above in Process_Globals
all = Value 'Assigning the value of the clicked item to our variable
Where is Value defined ?
You need to post more code to see where the probelm is.
In your post you show only two lines of code without the definition of Value therefore the question.
How do you fill the ListView ?
The problem is that you fill the ListView with strings.The first line is filled with text, the second line is filled with text or blank "" and the line is completed with a bitmap passed as AddTwoLinesAndBitmap parameter.
The problem is that you fill the ListView with strings.
So Value in the ListView1_ItemClick routine is the String of the first line and not a MyView type variable !
You should use AddTwoLinesAndBitmap2(Text1 As String, Text2 As String, Bitmap As Bitmap, ReturnValue As Object) to fill the ListView, where ReturnValue is the MyView type variable.
Dim Val1 as MyView
Val1.row1 = TextRow1
Val1.row2 = TextRow2
ListView1.AddTwoLinesAndBitmap2(TextRow1, TextRow2, Bitmap, Val1)
Sub ListView1_ItemClick (Position As Int, Value As Object)
Dim all As MyView ' Declaring a variable 'all' as the type we created above in Process_Globals
all = Value 'Assigning the value of the clicked item to our variable
End Sub