B4A Library [B4X] CLVSwipe - xCustomListView Swipe actions and pull to refresh

Status
Not open for further replies.
CLVSwipe is a class that adds "swipe actions" and pull to refresh features to the standard xCustomListView library.

It is compatible with B4A and B4i (currently not with B4J).
Both features are optional.


Using it is simple:

1. Add the class to your project. It depends on XUI, xCustomListView and ViewsEx v1.30+.
2. Initialize Swipe and pass the CustomListView.
3. In B4i, call Swipe.Resize when the page is resized.

Adding action commands:

- Set the action colors:
B4X:
Swipe.ActionColors = CreateMap("Delete": xui.Color_Red, "Do Something Else": xui.Color_Green, _
       "Action 1": xui.Color_Red, "Action 2": xui.Color_Blue, "Action 3": xui.Color_Yellow)
- Create the items values with Swipe.CreateItemValue:
B4X:
CustomListView1.AddTextItem($"Important item ${i} ..."$, Swipe.CreateItemValue("", Array("Delete", "Do Something Else")))
- Handle the ActionClicked event:
B4X:
Sub Swipe_ActionClicked (Index As Int, ActionText As String)

Pull to refresh:

- Create the PullToRefreshPanel panel. This is the panel that appears when the user pulls the list.
- Set it with Swipe.PullToRefreshPanel.
- Handle the RefreshRequested event. Make sure to call Swipe.RefreshCompleted when done.
- In B4i you need to call Swipe.ScrollChanged from the ScrollChanged event.

B4A and B4i projects are attached. Note that the class module is identical in both projects.

Updates

V1.13 - New ScrollingEnabled property - enables or disables scrolling.
V1.12 - Fixes an issue with the Resize method.
V1.11 - Fixes an issue with horizontal swipes when the list is empty.
v1.10 - Adds pull to refresh feature.

The class is included inside the project.
 

Attachments

  • CLVSwipeExample.zip
    17.9 KB · Views: 1,431
Last edited:

Luke3012

Member
Licensed User
Hi, I have a problem with this library.
I decided to use it for the pull to refresh feature, but as long as i initialize it I can't swipe with a horizontal custom listview that is put inside the custom listview where CLVSwipe has initialized.
Please, can you help me? I still want to use this Library for the useful Pull to Refresh feature.
Thank you
 

Luke3012

Member
Licensed User
Can you upload a small project that demonstrates it? It might be possible to disable the horizontal swipe detection to make it work.

There you go. In this example I'm using AHViewPager but it's also the same with a horizontal Custom Listview.
Thanks for the help!!!
 

Attachments

  • CLVSwipeExample.zip
    12.6 KB · Views: 416

Luke3012

Member
Licensed User
There is an error in this example. panelx(2) is never initialized.

For further discussion please start a new thread.

I know but this is a quick example that I just created to explain the problem, sorry I forgot that.
 
Status
Not open for further replies.
Top