CustomListView - A flexible list based on ScrollView

Status
Not open for further replies.

LucaMs

Expert
Licensed User
Longtime User
If I'm not mistaken, there is not a way to disable an Item and there is not an ItemLongClick event.

I made these changes.

Again if I'm not mistaken, my changes do not affect the original functionalities, so Erel could remove my comments (LM 1.0...) and update his version (to 1.21 ?).
 

Attachments

  • lm CustomListView.zip
    11.9 KB · Views: 307

bocker77

Active Member
Licensed User
Longtime User
I have a CustomListview and want to disable the item so it will not accept an event such as a Click. I get the panel and disable it but the event still gets fired. If the event is not on the item's panel then what is it on?

pnlTemp = clvAllies.GetPanel(i)
pnlTemp.Enabled = False
 

bocker77

Active Member
Licensed User
Longtime User
After thinking about this more it became obvious that the event is on the whole listview and not on an item. So what I would like to do isn't feasible. Please disregard my question in previous post (#425).
 

bocker77

Active Member
Licensed User
Longtime User
Thanks LucaMS and Erel.

LucaMS, I thought your changes that you have made to the CustomListView in post #424 was referring to just what I was wanting but was a little leery of replacing Erel's CustomListView. Also it was getting late and my head was spinning trying to fix other bugs in my program that trying to figure out one more piece of code seemed exhausting.

Erel, I went ahead and disabled all the other views that generate events in the item and made a check for the item's click and inform the user that that is not allowed. Your resolution will allow me to do what I originally wanted.

Again thanks to you both for responding to my question. It is much appreciated.
 

LucaMs

Expert
Licensed User
Longtime User
LucaMS, I thought your changes that you have made to the CustomListView in post #424 was referring to just what I was wanting but was a little leery of replacing Erel's CustomListView

I forget all so quickly :D...
so I'm not sure but my changes to Erel's CustomListView should not adversely interfere (in short, compatibility remains).
Few lines added.
 
Last edited:

LucianoB

Member
Licensed User
Longtime User
I' m not able to show a panel background image through a customlistview nor the background of customlistview itself. I have this code but the customlistview background color is always black instead of transparent.

B4X:
clv1.Initialize(Me, "clv1")
    pnlHistory.AddView(clv1.AsView, 0, 0, 100%x, 90%y)
 
    Dim listHistory As List
    listHistory.Initialize2(File.ReadList(File.DirAssets ,"History.txt"))
    For i = 0 To listHistory.Size -1
        clv1.AddTextItem(listHistory.Get(i),"")    'if I comment out this line then clv becomes transparent and shows panel background
    Next
 
    clv1.DefaultTextBackgroundColor = Colors.Transparent
    clv1.AsView.Color = Colors.Transparent
'    clv1.AsView.SetBackgroundImage(LoadBitmap( File.DirAssets, "background.jpg")) ' this doesn't set background

Any idea?
Thank you in advance.
 

Attachments

  • Screenshot_2016-05-26-16-01-31.jpg
    Screenshot_2016-05-26-16-01-31.jpg
    274.9 KB · Views: 337
Last edited:

ilan

Expert
Licensed User
Longtime User
hi

i am using CLV v1.20 in my app and i am getting in the IDE logs 3 times following line:

Class not found: net.sagital.callrec.customlistview, trying: net.vladi.callrec.customlistview

the app package name was in the beginning net.sagital.callrec then it was changed to net.vladi.callrec
i have removed the module CLV and also deleted it from the app folder and the imported it again after i changed the package name

can someone tell me why it is still trying to call it from the old package name and then from the new?

i need to mention that everything is working but the logs are just not clear for me

thanx, ilan
 

LucaMs

Expert
Licensed User
Longtime User
hi

i am using CLV v1.20 in my app and i am getting in the IDE logs 3 times following line:



the app package name was in the beginning net.sagital.callrec then it was changed to net.vladi.callrec
i have removed the module CLV and also deleted it from the app folder and the imported it again after i changed the package name

can someone tell me why it is still trying to call it from the old package name and then from the new?

i need to mention that everything is working but the logs are just not clear for me

thanx, ilan
https://www.b4x.com/android/forum/t...g-class-not-found-messages.38603/#post-228608
 

LucaMs

Expert
Licensed User
Longtime User
Can be useful a method to set ("replace") the value of an Item? (if I'm not mistaken it is missing and I have needed it to post an example).

I added (but not tested :p):
B4X:
Public Sub SetValue(Index As Int, Value As Object)
    items.RemoveAt(Index)
    items.InsertAt(Index, Value)
End Sub

If yes (if it is useful) it should be added also to "Pull to refresh"
 

Paul Edwards

Member
Licensed User
Longtime User
Hi,

How to change the background colour of an individual item before .AddTextItem ?

Paul

The native ListView is a optimized for very large lists. Instead of creating the views for each item, it reuses the same views when possible. This optimization makes it very difficult to customize the items.

CustomListView is an implementation of a list based on ScrollView.

CustomListView is suited for lists of up to 1000 or 2000 items.

Advantages of CustomListView:
  • Each item is made of a Panel that can hold any views.
  • Items can be modified at any time.
  • It is possible to insert or remove items from any position.
  • Each item can have a different height.
  • Items height can be set automatically based on the text (using AddTextItem).

Using CustomListView is simple:
- First you should initialize the list and add it to a panel or activity.
- Then you should add items.
Each item is made of a panel that holds other views.
AddTextItem is a convenient utility to add items made of a single label.

The attached example creates two lists:

View attachment 41397

The first list is made of simple text items.

In the second list each item is created by loading another layout file.
A nice advantage of using a layout file to create the cell, is that it allows us to use anchors and designer script to create a flexible layout that changes based on the screen size. Rotate the device to landscape to see it.


This class depends on the JavaObject and StringUtils libraries.
V1.20 - Better designer support. Example code simplified.
V1.10 - Adds designer support. CustomListView can now be added with the visual designer. Add a CustomView and then set its CustomType property to CustomListView.
 
Status
Not open for further replies.
Top