D Declan Well-Known Member Licensed User Longtime User May 3, 2020 #1 I am using this example: [B4X] [XUI] Expandable list based on xCustomListView Edit: Better to use CLVExpandable class: https://www.b4x.com/android/forum/threads/b4x-clvexpandable-allows-expanding-or-collapsing-xcustomlistview-items.106148/ Compatible with B4A, B4J and B4i. This example uses a slightly modified version of xCustomListView to create an expandable... www.b4x.com Click to expand... I have changed the name of the 2 X Buttons. What I need to achieve is to read the Panel Id when one of the two Buttons are Clicked Then action the Button function to Accept or Reject - On Reject, I must delete the item from the list I have tried the following to get panel id: B4X: Copy Sub btnAccept_Click Dim v As Button v = Sender Dim MyIndex As Int Dim MyIndex = clv1.GetPanel(v) LogColor("Button Accept: " & MyIndex, Colors.blue) End Sub How do I read the lblTitle.text of a panel on the Button_Click event I always get :Item# 20" - the last item in the CustomListView, not the Item that I Clicked Last edited: May 3, 2020
I am using this example: [B4X] [XUI] Expandable list based on xCustomListView Edit: Better to use CLVExpandable class: https://www.b4x.com/android/forum/threads/b4x-clvexpandable-allows-expanding-or-collapsing-xcustomlistview-items.106148/ Compatible with B4A, B4J and B4i. This example uses a slightly modified version of xCustomListView to create an expandable... www.b4x.com Click to expand... I have changed the name of the 2 X Buttons. What I need to achieve is to read the Panel Id when one of the two Buttons are Clicked Then action the Button function to Accept or Reject - On Reject, I must delete the item from the list I have tried the following to get panel id: B4X: Copy Sub btnAccept_Click Dim v As Button v = Sender Dim MyIndex As Int Dim MyIndex = clv1.GetPanel(v) LogColor("Button Accept: " & MyIndex, Colors.blue) End Sub How do I read the lblTitle.text of a panel on the Button_Click event I always get :Item# 20" - the last item in the CustomListView, not the Item that I Clicked
LucaMs Expert Licensed User Longtime User May 3, 2020 #2 B4X: Copy Sub btnAccept_Click Dim Index As Int = clv1.GetItemFromView(Sender) Dim pnl As Panel = clv1.GetPanel(Index) '... Upvote 0
B4X: Copy Sub btnAccept_Click Dim Index As Int = clv1.GetItemFromView(Sender) Dim pnl As Panel = clv1.GetPanel(Index) '...
D Declan Well-Known Member Licensed User Longtime User May 4, 2020 #3 @LucasM - Thanks However, when I run: B4X: Copy Sub btnAccept_Click Dim v As Button v = Sender Dim Index As Int = clv1.GetItemFromView(Sender) Dim pnl As Panel = clv1.GetPanel(Index) Dim MyIndex As String = Index Dim MyPanel As String = pnl LogColor("Button Accept: " & v.text & "Index: " & MyIndex & "Text; " & "Panel: " & MyPanel & "Text; " & lblTitle.text, Colors.blue) CollapseItem(MyExpandedID) It always returns "Item #20" and not the actual Panel Title text that the Button is in: B4X: Copy Button Accept: AcceptIndex: 1Text; Panel: (BALayout): Left=0, Top=0, Width=1080, Height=420, Tag=trueText; Item #20 Upvote 0
@LucasM - Thanks However, when I run: B4X: Copy Sub btnAccept_Click Dim v As Button v = Sender Dim Index As Int = clv1.GetItemFromView(Sender) Dim pnl As Panel = clv1.GetPanel(Index) Dim MyIndex As String = Index Dim MyPanel As String = pnl LogColor("Button Accept: " & v.text & "Index: " & MyIndex & "Text; " & "Panel: " & MyPanel & "Text; " & lblTitle.text, Colors.blue) CollapseItem(MyExpandedID) It always returns "Item #20" and not the actual Panel Title text that the Button is in: B4X: Copy Button Accept: AcceptIndex: 1Text; Panel: (BALayout): Left=0, Top=0, Width=1080, Height=420, Tag=trueText; Item #20
Erel B4X founder Staff member Licensed User Longtime User May 4, 2020 #4 The best option is to store all the information you need in the Value object. Not in any UI element. Upvote 0
D Declan Well-Known Member Licensed User Longtime User May 4, 2020 #5 Erel said: The best option is to store all the information you need in the Value object. Not in any UI element. Click to expand... Sorry, I don't understand Upvote 0
Erel said: The best option is to store all the information you need in the Value object. Not in any UI element. Click to expand... Sorry, I don't understand
Erel B4X founder Staff member Licensed User Longtime User May 4, 2020 #6 Please upload a small project with the list. Upvote 0
D Declan Well-Known Member Licensed User Longtime User May 4, 2020 #7 The attached project is an edited version of the example in post 1. In my main project, I am using Firebase notifications. The "Title" and "Body" of the Firebase notification message is comma delimited and includes a unique ID. When the Firebase message is received, it is loaded into the CustomListView and the user has the option to Accept or Reject the notification (btnAccept / btnReject) If the user clicks btnAccept, I parse the notification string and write to SQLite table. Therefore, I must be able to read the full Text in the CustomListView If the user clicks btnReject, I simply remove the CustomListView item. I hope this makes sense Attachments 1.zip 1.zip 15.5 KB · Views: 347 Upvote 0
The attached project is an edited version of the example in post 1. In my main project, I am using Firebase notifications. The "Title" and "Body" of the Firebase notification message is comma delimited and includes a unique ID. When the Firebase message is received, it is loaded into the CustomListView and the user has the option to Accept or Reject the notification (btnAccept / btnReject) If the user clicks btnAccept, I parse the notification string and write to SQLite table. Therefore, I must be able to read the full Text in the CustomListView If the user clicks btnReject, I simply remove the CustomListView item. I hope this makes sense
Erel B4X founder Staff member Licensed User Longtime User May 4, 2020 #8 I'm sorry but I missed the fact that you are using an old and deprecated solution. There is a reason why it says: Remove CustomListView class. Add CLVExpanded and xCustomListView library. Upvote 0
I'm sorry but I missed the fact that you are using an old and deprecated solution. There is a reason why it says: Remove CustomListView class. Add CLVExpanded and xCustomListView library.
D Declan Well-Known Member Licensed User Longtime User May 4, 2020 #9 Erel said: Remove CustomListView class. Add CLVExpanded and xCustomListView library. Click to expand... Ok, Done Result is the same Latest project with CLVExpanded and xCustomListView library. Attachments 1.zip 1.zip 11.8 KB · Views: 348 Upvote 0
Erel said: Remove CustomListView class. Add CLVExpanded and xCustomListView library. Click to expand... Ok, Done Result is the same Latest project with CLVExpanded and xCustomListView library.
Erel B4X founder Staff member Licensed User Longtime User May 4, 2020 #10 Declan said: Result is the same Click to expand... That's expected. lblTitle will point to the last one that was added. I wanted to show you how to fix the code however I can't as you haven't implemented CLVExpandable correctly. [B4X] CLVExpandable - Allows expanding or collapsing xCustomListView items This class replaces the custom CustomListView module (https://www.b4x.com/android/forum/threads/b4x-xui-expandable-list-based-on-xcustomlistview.86449/). It works with the standard xCustomListView library. It is compatible with B4A, B4i and B4J. Instructions: An expandable item layout should... www.b4x.com Upvote 0
Declan said: Result is the same Click to expand... That's expected. lblTitle will point to the last one that was added. I wanted to show you how to fix the code however I can't as you haven't implemented CLVExpandable correctly. [B4X] CLVExpandable - Allows expanding or collapsing xCustomListView items This class replaces the custom CustomListView module (https://www.b4x.com/android/forum/threads/b4x-xui-expandable-list-based-on-xcustomlistview.86449/). It works with the standard xCustomListView library. It is compatible with B4A, B4i and B4J. Instructions: An expandable item layout should... www.b4x.com
D Declan Well-Known Member Licensed User Longtime User May 4, 2020 #11 Ok, Done. The attached project runs. btnReject_Click works and removes the item from the list Attachments 2.zip 2.zip 11.4 KB · Views: 354 Upvote 0
Erel B4X founder Staff member Licensed User Longtime User May 4, 2020 #12 Were you able to solve the original problem? Upvote 0
Erel B4X founder Staff member Licensed User Longtime User May 4, 2020 #14 1: Code: Copy For i = 1 To 20 Dim Title As String = "Item #" & i Dim p As B4XView = CreateItem(Rnd(0xFF000000, 0xFFFFFFFF), Title, Rnd(100dip, 250dip) + 60dip) clv1.Add(p, expandable.CreateValue(p, Title)) Next 2: Code: Copy Sub btnAccept_Click Dim Index As Int = clv1.GetItemFromView(Sender) Dim text As String = expandable.GetValue(Index) Log(text) End Sub If you need to store more information then use a custom type or array. Upvote 0
1: Code: Copy For i = 1 To 20 Dim Title As String = "Item #" & i Dim p As B4XView = CreateItem(Rnd(0xFF000000, 0xFFFFFFFF), Title, Rnd(100dip, 250dip) + 60dip) clv1.Add(p, expandable.CreateValue(p, Title)) Next 2: Code: Copy Sub btnAccept_Click Dim Index As Int = clv1.GetItemFromView(Sender) Dim text As String = expandable.GetValue(Index) Log(text) End Sub If you need to store more information then use a custom type or array.
Pere Vinyes Member Licensed User Longtime User Jun 8, 2020 #16 By the way: say a xCustomListview (CLV1) that contains a layout.pnl (p.LoadLayout("Items3") containing another xCustomListview (CLV2) that have a Checkbox (CHK1). All works as expected and a click on CHK1 is correctly fired. The question is: How may I read the status of CHK1 and the index of CLV1 and CLV2 of the CHK1 clicked? Upvote 0
By the way: say a xCustomListview (CLV1) that contains a layout.pnl (p.LoadLayout("Items3") containing another xCustomListview (CLV2) that have a Checkbox (CHK1). All works as expected and a click on CHK1 is correctly fired. The question is: How may I read the status of CHK1 and the index of CLV1 and CLV2 of the CHK1 clicked?
Erel B4X founder Staff member Licensed User Longtime User Jun 9, 2020 #17 You should never post questions in existing threads. There should only be a question in the very first post. Upvote 0
You should never post questions in existing threads. There should only be a question in the very first post.