B BreonB57 New Member Jul 13, 2020 #1 Hi there, I am new to B4A so please bear with me. I have a customlistview which has items in it. I am trying to make it so that if a user clicks on an item, it will be able to retrieve all details about that item (The text and value). I have got the value, but I've got no idea about how to find the text. Please see my code below B4X: Sub CustomListView1_ItemClick (Index As Int, Value As Object) Dim search As String search = CustomListView1.GetValue End Sub Search is the text Thanks
Hi there, I am new to B4A so please bear with me. I have a customlistview which has items in it. I am trying to make it so that if a user clicks on an item, it will be able to retrieve all details about that item (The text and value). I have got the value, but I've got no idea about how to find the text. Please see my code below B4X: Sub CustomListView1_ItemClick (Index As Int, Value As Object) Dim search As String search = CustomListView1.GetValue End Sub Search is the text Thanks
M Mahares Expert Licensed User Longtime User Jul 13, 2020 #2 BreonB57 said: Search is the text Click to expand... Code: Sub CustomListView1_ItemClick (Index As Int, Value As Object) Dim search As String = Value End Sub Upvote 0
BreonB57 said: Search is the text Click to expand... Code: Sub CustomListView1_ItemClick (Index As Int, Value As Object) Dim search As String = Value End Sub
B BreonB57 New Member Jul 13, 2020 #3 Mahares said: Code: Sub CustomListView1_ItemClick (Index As Int, Value As Object) Dim search As String = Value End Sub Click to expand... Thanks but isn't the value different to the text? I'm looking for the text and that seems to return a value instead. Upvote 0
Mahares said: Code: Sub CustomListView1_ItemClick (Index As Int, Value As Object) Dim search As String = Value End Sub Click to expand... Thanks but isn't the value different to the text? I'm looking for the text and that seems to return a value instead.
Erel B4X founder Staff member Licensed User Longtime User Jul 13, 2020 #4 You must provide more information. What text? How are you adding items? We cannot guess those things. Upvote 0
You must provide more information. What text? How are you adding items? We cannot guess those things.
B BreonB57 New Member Jul 13, 2020 #5 Erel said: You must provide more information. What text? How are you adding items? We cannot guess those things. Click to expand... Sorry, I am adding items like this B4X: CustomListView1.AddTextItem(text, value) I am just trying to find a way to access the text value that is associated with the list items. The actual text that displays to the user. Please let me know if I need to provide more info Thanks Upvote 0
Erel said: You must provide more information. What text? How are you adding items? We cannot guess those things. Click to expand... Sorry, I am adding items like this B4X: CustomListView1.AddTextItem(text, value) I am just trying to find a way to access the text value that is associated with the list items. The actual text that displays to the user. Please let me know if I need to provide more info Thanks
mangojack Expert Licensed User Longtime User Jul 13, 2020 #6 This might help .. Code: Sub CustomListView1_ItemClick(Index As Int, Value As Object) Dim pnl As B4XView = CustomListView1.GetPanel(Index) dim myText as String = pnl.GetView(0).Text 'view(0) = 1st label on panel.. refer order in Designer ViewTree for Item/Row layout This can vary depending on your CLV layout etc (are your row items views contained within a panel ?).. but should give you the idea. Upvote 0
This might help .. Code: Sub CustomListView1_ItemClick(Index As Int, Value As Object) Dim pnl As B4XView = CustomListView1.GetPanel(Index) dim myText as String = pnl.GetView(0).Text 'view(0) = 1st label on panel.. refer order in Designer ViewTree for Item/Row layout This can vary depending on your CLV layout etc (are your row items views contained within a panel ?).. but should give you the idea.
Erel B4X founder Staff member Licensed User Longtime User Jul 13, 2020 #7 Very good solution: create a custom type with all the information you need and store an instance of this type as the value. Good solution: Code: Dim text As String = CustomListView1.GetPanel(Index).GetView(0).Text Upvote 0
Very good solution: create a custom type with all the information you need and store an instance of this type as the value. Good solution: Code: Dim text As String = CustomListView1.GetPanel(Index).GetView(0).Text