B4A Library [B4X] [XUI] xCustomListView - cross platform CustomListView

Status
Not open for further replies.
Update: As several other libraries depend on xCustomListView library, it is no longer recommended to use the code module. Use the library instead. There are several extension classes that add more features to xCLV. They are listed at the end of this post.

Video tutorial:


xCustomListView is an implementation of CustomListView based on XUI library. It provides all the features of the original CustomListView and it is compatible with B4A, B4J and B4i.

SS-2017-09-27_11.15.59.png
SS-2017-09-27_11.16.26.png
SS-2017-09-27_11.16.50.png


SS-2017-12-27_16.20.44.png


This class replaces the platform specific CustomListView classes. It is recommended to use this one for new projects.

Change log:

- V1.74 - Fixes a bug with JumpToItem (B4i).
- V1.72 (B4A only) - Fixes an issue where the designer typeface is not set when calling AddTextItem.
- V1.71 (B4i only) - Fixes an issue related to iOS 9- devices.
- V1.70 - ItemLongClick event (right click in B4J).
- V1.68 - Fixes a bug with ResizeItem / ReplaceAt and lists with single item.
- PressedColor is now a public field.
- Setting the PressedColor to a transparent color disables the item click color animation. This is useful if you want to replace it with your own implementation.
- V1.66 - Improves the text measurement of text items in B4J.
- V1.65 - Fixes an issue in B4i only where the CSBuilder colors were ignored.
- V1.64 - Fixes an issue with ScrollToItem / JumpToItem in B4i.
- V1.63 - Bug fixes, Refresh method to force VisibleRangeChanged to be raised, several private subs are now public, designer property to hide the scroll bar.
- V1.54 - Allows using CSBuilder with AddTextItem in B4i (it is also supported in B4A).
- V1.53 - Fixes an issue with VisibleRangeChanged event and CLV.Clear
- V1.52 - Fixes an issue with CLV.RemoveAt
- V1.51 - Fixes an issue which caused the LastVisibleIndex and FirstVisibleIndex properties to be hidden.

- V1.50 - Large update.
- V1.20 - Adds support for horizontal orientation.
Set it in the designer.
Add items like this:
B4X:
clv2.Add(CreateListItem($"Item #${i}"$, 160dip, clv2.AsView.Height), $"Item #${i}"$)
'Instead of
'clv2.Add(CreateListItem($"Item #${i}"$, clv2.AsView.Width, 160dip), $"Item #${i}"$)

Don't use the source code. Use the preinstalled xCustomListView library instead.
Libraries such as XUI Views depend on the library and will not work properly with the module.

Extension classes:

CLVExpandable (B4X) - Allows expanding and collapsing items: https://www.b4x.com/android/forum/t...g-or-collapsing-xcustomlistview-items.106148/
CLVSwipe (B4A and B4i) - Adds swipe actions and swipe to refresh feature: https://www.b4x.com/android/forum/threads/98252/#content
CLVHeader - (B4X) - Adds a nice animated header to the list: https://www.b4x.com/android/forum/t...ted-header-to-xcustomlistview.105343/#content
CLVSelections (B4X) - Adds more selection modes: https://www.b4x.com/android/forum/t...d-selection-modes-for-xcustomlistview.114364/
CLVNested (B4A) - Allows nesting a CLV inside a CLV item: https://www.b4x.com/android/forum/threads/clvnested-allows-nesting-clvs.107742/#content
PreoptimizedCLV (B4X) - Lazy loading + fast scroll extension: https://www.b4x.com/android/forum/t...loading-extension-for-xcustomlistview.115289/

 

Attachments

  • CustomListView.bas
    19.8 KB · Views: 2,238
  • CLVExample.zip
    20.2 KB · Views: 2,971
Last edited:

luke2012

Well-Known Member
Licensed User
Longtime User
The attached project is a B4A project. To run xCustomListView on iOS device I can import the code and the class (as it is) within a B4i project?
 

Rusty

Well-Known Member
Licensed User
Longtime User
In post #14, I asked if one could put EditTexts in the xCustomListView.
In fact, you can :)
I have added rows of "items" into the clv that contain panels which contain a label and an EditText view.
It is important to my application that when the EditText gains/loses focus that I suppress the soft keyboard with IME and then show my own custom keyboard.
When the EditText is touched the FIRST time, this works great :)
If you exit the EditText (change focus to something else), the custom keyboard disappears as appropriate, but when you touch the same EditText to regain focus, the Focus Changed event does NOT fire...
However, the soft keyboard does pop-up...
When you touch the soft keyboard, the Focus Changed event then DOES fire...
Am I doing something wrong? When I load the CLV, I load a .bal file with the EditText defined within...
Any ideas are welcome...
Rusty

UPDATE: The Focus Changed event does not fire when you touch the soft keyboard, it is the TextChanged event...
FURTHER UPDATE: I updated Erel's example and placed an edittext within the .Bal file. It generated the CLV with the label, button, chechbox and edittext views as planned.
When I touch the edittext, the hasfocus fires. If i touch any other edittext, the hasfocus fires, if i touch a button, checkbox or label, the hasfocus does NOT fire.
Is there a way to make the focus change when another type view is touched?
 
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
FURTHER UPDATE: I updated Erel's example and placed an edittext within the .Bal file. It generated the CLV with the label, button, chechbox and edittext views as planned.
When I touch the edittext, the hasfocus fires. If i touch any other edittext, the hasfocus fires, if i touch a button, checkbox or label, the hasfocus does NOT fire.
Is there a way to make the focus change when another type view is touched?
Please start a new thread for this question.
 

Sapta

Member
Licensed User
Longtime User
Hi @Erel

Can I request for the next version ?
At _ReachEnd event, can be added ProgressBar at the bottom like PullToRefresh like example here
Thank you
 

Dadaista

Active Member
Licensed User
Longtime User
Hi

I have changed old CLV for new CLV

I get this error

B4X:
Registo conectado a:  Sunstech TAB109QCBT
--------- beginning of main
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
customlistview_designercreateview (B4A line: 46)
sv.ScrollViewInnerPanel.Color = xui.PaintOrColorT
java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object reference
   at anywheresoftware.b4a.objects.B4XViewWrapper$XUI.PaintOrColorToColor(B4XViewWrapper.java:527)
   at com.dbsaiz.caja.venta.free.customlistview._designercreateview(customlistview.java:475)
   at java.lang.reflect.Method.invoke(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:372)
   at anywheresoftware.b4a.BA.raiseEvent2(BA.java:186)
   at anywheresoftware.b4a.objects.CustomViewWrapper.AfterDesignerScript(CustomViewWrapper.java:67)
   at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:162)
   at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:209)
   at com.dbsaiz.caja.venta.free.main._activity_create(main.java:516)
   at java.lang.reflect.Method.invoke(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:372)
   at anywheresoftware.b4a.BA.raiseEvent2(BA.java:186)
   at com.dbsaiz.caja.venta.free.main.afterFirstLayout(main.java:102)
   at com.dbsaiz.caja.venta.free.main.access$000(main.java:17)
   at com.dbsaiz.caja.venta.free.main$WaitForLayout.run(main.java:80)
   at android.os.Handler.handleCallback(Handler.java:739)
   at android.os.Handler.dispatchMessage(Handler.java:95)
   at android.os.Looper.loop(Looper.java:135)
   at android.app.ActivityThread.main(ActivityThread.java:5254)
   at java.lang.reflect.Method.invoke(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:372)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
Object context is paused. Ignoring CallSubDelayed: AfterLoadLayout
Object context is paused. Ignoring CallSubDelayed: AfterLoadLayout

My CLV's are created in run time

How can I solve it?
 
Last edited:

janderkan

Well-Known Member
Licensed User
Longtime User
Hi All
I have downloaded the project attached to post #1 (v1.20)
It compiles and runs with no problems.
But when i add a new layout to the project, I get the following error when calling 'Activity.LoadLayout("2")'
java.lang.RuntimeException: java.lang.RuntimeException: CustomView CustomType property was not set.
(I did search the forum, but did not find any solution)
In the designer the Custom type property is greyed out, so it is not possible to change it.

Starting a new project does not help.

Biggest problem is that an existing project where I use CustomListView v1.76 suddenly have the exact same problem.

B4A - 7.80
JDK - 8.152
Android 27

Latest info !!
Downgraded to B4A 7.30 - Problem solved :) !!!! or :( ...

Latest-Latest info !!
7.30 - 7_3.jpg 7,80 - 7_8.jpg
In the designer when I select 'Add View' the arrow next to CustomView is missing in B4A 7.80
 
Last edited:

XbNnX_507

Active Member
Licensed User
Longtime User
is it possible to use VisibleRangeChanged event to reuse the views in runtime instead of creating and removing these?
( similar to the way recycle view works).
 

Angel Garcia

Member
Licensed User
Hi All,
I'm trying to use a CLV with horizontal scrolling with no success, i set it as the tutorial:
Dim p As B4XView = xui.CreatePanel("")
p.SetLayoutAnimated(0,0,0,180dip,CLVMap.AsView.Height)
CLVMap.Add(p, cd)
But i'm still getting items added vertically, any help would be appreciated.

EDIT:
LOL i didn't see it "set it in the designer", ROFLCOPTER, i'm sorry :(

Thanks!
 
Last edited:

Claudio Oliveira

Active Member
Licensed User
Longtime User
@Erel ,
Apparently there's a mistake in RemoveAt sub.
When there are text items in the list, RemoveAt sub calculates NewOffset values incorrectly.

This code line
B4X:
Dim NewOffset As Int = item.Offset - item.Size - DividerSize
Should be like this
B4X:
Dim NewOffset As Int = item.Offset - RemoveItem.Size - DividerSize

Regards
 
Status
Not open for further replies.
Top