Mar 16, 2013 Replies: 51 Intro: These are simple panels that can be easily expanded and collapsed with a small animation. Future Improvements: There can be many improvements to this class, and I would love to learn what the best coding style for classes is. - Coding style (what is exposed and what is not, comments, handling views) License: Free to use. But post any modifications, and improvements back here so the community version becomes better. Better Demo apk: See here EDIT: Class improved with better animations with Informatix's NOA library. Sample available in this post: http://www.b4x.com/android/forum/threads/class-expandable-panels.27366/page-2#post-275751 Attachments expSample.png 30.7 KB · Views: 2,387 ExpandablePanelsSample.zip ExpandablePanelsSample.zip 7.5 KB · Views: 1,544 Last edited: Sep 25, 2014 Click to expand...
Intro: These are simple panels that can be easily expanded and collapsed with a small animation. Future Improvements: There can be many improvements to this class, and I would love to learn what the best coding style for classes is. - Coding style (what is exposed and what is not, comments, handling views) License: Free to use. But post any modifications, and improvements back here so the community version becomes better. Better Demo apk: See here EDIT: Class improved with better animations with Informatix's NOA library. Sample available in this post: http://www.b4x.com/android/forum/threads/class-expandable-panels.27366/page-2#post-275751
Informatix Expert Licensed User Longtime User Mar 17, 2013 #3 To avoid having multiple event handlers, you can use the Tag property to set the "name" or ID of the panel. This tag is read in the event handler to identify the proper panel.
To avoid having multiple event handlers, you can use the Tag property to set the "name" or ID of the panel. This tag is read in the event handler to identify the proper panel.
thedesolatesoul Expert Licensed User Longtime User Mar 18, 2013 #4 Thanks for the tip Informatix. I updated the sample to return itself in the click handler.
bluejay Active Member Licensed User Longtime User Mar 19, 2013 #5 Would it be better to use: Code: CallSub(module,Eventname &"_Resize") for the callback to refresh views? This would link better with the Initialize for each expandablePanel.
Would it be better to use: Code: CallSub(module,Eventname &"_Resize") for the callback to refresh views? This would link better with the Initialize for each expandablePanel.
thedesolatesoul Expert Licensed User Longtime User Mar 20, 2013 #6 Good idea bluejay, thanks. Updated.
merlin2049er Well-Known Member Licensed User Longtime User May 2, 2014 #8 Sweet, got to add this to my library. Is there a way to customize the animation?
thedesolatesoul Expert Licensed User Longtime User May 2, 2014 #9 I'll be happy to. How do you want to customize it?
merlin2049er Well-Known Member Licensed User Longtime User May 2, 2014 #10 How about customizing some of the animation styles?
thedesolatesoul Expert Licensed User Longtime User May 2, 2014 #11 Make some suggestions...videos are even better At the moment it only expands linearly.
merlin2049er Well-Known Member Licensed User Longtime User May 16, 2014 #12 Great, so you can put anything in these expanding panels? I thought maybe, an image, that would expand to show a listview. Something like that. Maybe a transitions effect as expanding.
Great, so you can put anything in these expanding panels? I thought maybe, an image, that would expand to show a listview. Something like that. Maybe a transitions effect as expanding.
thedesolatesoul Expert Licensed User Longtime User May 16, 2014 #13 Yes, you can put anything you can normally put in a panel. Be careful with a listview as if your panels are in a scrollview, your listview will not be able to scroll.
Yes, you can put anything you can normally put in a panel. Be careful with a listview as if your panels are in a scrollview, your listview will not be able to scroll.
tuhatinhvn Active Member Licensed User Longtime User May 18, 2014 #14 can you give an example expadable panel with each panel load each laylout file?
thedesolatesoul Expert Licensed User Longtime User May 18, 2014 #15 All you need to do is after you initialize all the other parameters, load the layout by: Code: expPnls(i).AsPanel.LoadLayout("my_layout")
All you need to do is after you initialize all the other parameters, load the layout by: Code: expPnls(i).AsPanel.LoadLayout("my_layout")
B bluedude Well-Known Member Licensed User Longtime User Jun 19, 2014 #16 Hi thedesolatesoul, I like these and would want to use them. I need something that I cannot get to seem working (works with Listview and custom listview): - I want to add a layouts with a checkbox and some other stuff. When clicking on the scrollview items it shows up another activity where the TAG is a record id, this works. Second I want to use the checkbox in the scrollview to check the record with a certain TAG to be "checked". How do I need to do the event handler for the checkbox when it is in the scrollview? I have the common way to get the correct checkbox but working with sender and getview isn't working for some reason. Any suggestions?
Hi thedesolatesoul, I like these and would want to use them. I need something that I cannot get to seem working (works with Listview and custom listview): - I want to add a layouts with a checkbox and some other stuff. When clicking on the scrollview items it shows up another activity where the TAG is a record id, this works. Second I want to use the checkbox in the scrollview to check the record with a certain TAG to be "checked". How do I need to do the event handler for the checkbox when it is in the scrollview? I have the common way to get the correct checkbox but working with sender and getview isn't working for some reason. Any suggestions?
thedesolatesoul Expert Licensed User Longtime User Jun 19, 2014 #17 I cannot understand what you are saying. Can you explain it better or attach a project? (Also are you loading the same layout into multiple panels? Is that the problem?)
I cannot understand what you are saying. Can you explain it better or attach a project? (Also are you loading the same layout into multiple panels? Is that the problem?)
B bluedude Well-Known Member Licensed User Longtime User Jun 19, 2014 #18 Hi, yes, i'm loading one layout (Label, checkbox and other views) and want to get track of clicks done on checkbox in all these loaded layouts. The TAG property of all the added panels are set to a unique record ID. When clicking the checkbox it should get the panel TAG (recordid) and do something (updating that record to "changed"). Normally I would do this with sender etc. but I got slightly confused Cheers,
Hi, yes, i'm loading one layout (Label, checkbox and other views) and want to get track of clicks done on checkbox in all these loaded layouts. The TAG property of all the added panels are set to a unique record ID. When clicking the checkbox it should get the panel TAG (recordid) and do something (updating that record to "changed"). Normally I would do this with sender etc. but I got slightly confused Cheers,
thedesolatesoul Expert Licensed User Longtime User Jun 19, 2014 #20 I see. Now the memories come back flowing to me! I had the same problem, i.e. loading the same layout in two panels, I was unable to distinguish between them in the events. In my case I just used two layouts. However for you, I think you need to getParent and then get the tag. Something like this: Code: 'Returns the index of the panel/item that holds the given view. Public Sub GetIDFromView(v As View) As Int Dim r As Reflector Dim parent As Object r.Target = v parent = r.RunMethod("getParent") Return parent.Tag End Sub
I see. Now the memories come back flowing to me! I had the same problem, i.e. loading the same layout in two panels, I was unable to distinguish between them in the events. In my case I just used two layouts. However for you, I think you need to getParent and then get the tag. Something like this: Code: 'Returns the index of the panel/item that holds the given view. Public Sub GetIDFromView(v As View) As Int Dim r As Reflector Dim parent As Object r.Target = v parent = r.RunMethod("getParent") Return parent.Tag End Sub