B4A Library [Class] Expandable Panels

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.basic4ppc.com/android/forum/threads/class-expandable-panels.27366/page-2#post-275751
 

Attachments

  • expSample.png
    expSample.png
    30.7 KB · Views: 1,716
  • ExpandablePanelsSample.zip
    7.5 KB · Views: 984
Last edited:

bluejay

Active Member
Licensed User
Longtime User
Would it be better to use:

B4X:
   CallSub(module,Eventname &"_Resize")

for the callback to refresh views?

This would link better with the Initialize for each expandablePanel.
 

merlin2049er

Well-Known Member
Licensed User
Longtime User
Sweet, got to add this to my library. Is there a way to customize the animation?
 

merlin2049er

Well-Known Member
Licensed User
Longtime User
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.
 

bluedude

Well-Known Member
Licensed User
Longtime User
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?
 

bluedude

Well-Known Member
Licensed User
Longtime User
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
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:

B4X:
'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
 
Top