CustomListView - A flexible list based on ScrollView

Status
Not open for further replies.

Florin

Member
Licensed User
Longtime User
Thanks.
I've seen it before, does dot help at all, pretty sketchy. Anyway, b4a has a long way to go ....
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
I don't understand your comment. CustomListView class is not an integral part of B4A. It is a class or example like many others.

As the source code is included you can quite easily see how it works and use it or modify it as you need.

If you have any specific question about it then we will be happy to help you.
 

shaffnert03

Member
Licensed User
Longtime User
Specific question on this: I'm using this class and have an instance where the list may sometimes be smaller than the screen. The color of the area below the list is then the same as the color of the dividers, as set in the class code.

Is there a way to change this section below without changing the dividers?

A picture of what I mean is below. In it the divider color has been set to yellow. Unfortunately when the list is shorter than the screen this means the area below is also yellow. How do I change that area below without changing the dividers?
 

Attachments

  • Screenshot_2013-12-03-19-39-34.png
    Screenshot_2013-12-03-19-39-34.png
    47.7 KB · Views: 406

Antti Mauranen

Member
Licensed User
Longtime User
I experiment with the original example of CustomListView and I get a little bit strange behaviour. The text size of clv1 grows when I flip my tablet from vertical to horizontal orientation and vice versa. This happens a couple of times and then the text size goes back to original and does not grow anymore. The minHeight in InsertAtTextItem seems to be growing, no idea why.

I have Nexus 7 2012 (if that mathers) and I did this because I want to save the list when the orientation changes and was experimenting that.
 

Antti Mauranen

Member
Licensed User
Longtime User
Yes. I write the DefaultTextSize to log and get like below. Sorry, quite a long post.

'Inserts a text item at the specified index.
Public Sub InsertAtTextItem(Index As Int, Text As String, Value As Object)
Dim pnl As Panel
pnl.Initialize("")
Dim lbl As Label
lbl.Initialize("")
lbl.Gravity = Bit.OR(Gravity.CENTER_VERTICAL, Gravity.LEFT)
pnl.AddView(lbl, 5dip, 2dip, sv.Width - 5dip, 20dip)
lbl.Text = Text
Log("DefaultTextSize: " & DefaultTextSize)
lbl.TextSize = DefaultTextSize
lbl.TextColor = DefaultTextColor
If DefaultTextBackground <> Null Then
pnl.Background = DefaultTextBackground
Else
pnl.Color = DefaultTextBackgroundColor
End If
Dim minHeight As Int
minHeight = su.MeasureMultilineTextHeight(lbl, Text)
lbl.Height = Max(50dip, minHeight)
InsertAt(Index, pnl, lbl.Height + 2dip, Value)
End Sub

** Activity (main) Resume **
** Activity (main) Pause, UserClosed = true **
** Activity (main) Create, isFirst = true **
DefaultTextSize: 26
DefaultTextSize: 26
DefaultTextSize: 26
DefaultTextSize: 26
DefaultTextSize: 26
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (main) Create, isFirst = false **
DefaultTextSize: 33
DefaultTextSize: 33
DefaultTextSize: 33
DefaultTextSize: 33
DefaultTextSize: 33
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (main) Create, isFirst = false **
DefaultTextSize: 43
DefaultTextSize: 43
DefaultTextSize: 43
DefaultTextSize: 43
DefaultTextSize: 43
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (main) Create, isFirst = false **
DefaultTextSize: 54
DefaultTextSize: 54
DefaultTextSize: 54
DefaultTextSize: 54
DefaultTextSize: 54
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (main) Create, isFirst = false **
DefaultTextSize: 69
DefaultTextSize: 69
DefaultTextSize: 69
DefaultTextSize: 69
DefaultTextSize: 69
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (main) Create, isFirst = false **
DefaultTextSize: 88
DefaultTextSize: 88
DefaultTextSize: 88
DefaultTextSize: 88
DefaultTextSize: 88
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (main) Create, isFirst = false **
DefaultTextSize: 113
DefaultTextSize: 113
DefaultTextSize: 113
DefaultTextSize: 113
DefaultTextSize: 113
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (main) Create, isFirst = false **
DefaultTextSize: 143
DefaultTextSize: 143
DefaultTextSize: 143
DefaultTextSize: 143
DefaultTextSize: 143
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (main) Create, isFirst = false **
DefaultTextSize: 182
DefaultTextSize: 182
DefaultTextSize: 182
DefaultTextSize: 182
DefaultTextSize: 182
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (main) Create, isFirst = false **
DefaultTextSize: 232
DefaultTextSize: 232
DefaultTextSize: 232
DefaultTextSize: 232
DefaultTextSize: 232
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (main) Create, isFirst = false **
DefaultTextSize: 26
DefaultTextSize: 26
DefaultTextSize: 26
DefaultTextSize: 26
DefaultTextSize: 26
** Activity (main) Resume **
 

Antti Mauranen

Member
Licensed User
Longtime User
Yes, of course. I noticed this with the code I had changed and though that it was something I did. Then I unzipped the original again and it had the same behaviour. And unzipped again when you asked. Same thing.

By the way, I use CM in my tablet.
 

Antti Mauranen

Member
Licensed User
Longtime User
I commented out AutoScaleAll and growing stops. Comes back when uncomment.

'All variants script
'AutoScaleAll
clv1.SetLeftAndRight(0, 100%x)
clv1.SetTopAndBottom(0, 45%y)
 

JakeBullet70

Well-Known Member
Licensed User
Longtime User
How can I add a new event? I want to add a LONG click event to the panel

I copied the code of the regular CLICK event and did it like below.

B4X:
Private Sub Panel_LongClick
    If SubExists(CallBack, EventName & "_LongClick") Then
        Dim v As View
        v = Sender
        CallSub3(CallBack, EventName & "_LongClick", v.Tag, items.Get(v.Tag))
    End If
End Sub

This does not work, is there a way to add the long click event?

On another note, I do like that this is not compiled to a library but is code because we all can learn from it and modify it as we wish.
 

JakeBullet70

Well-Known Member
Licensed User
Longtime User
Thanks all, its working.

Problem was hardware, my programming computer is a 15in ACER Touch Screen. For what ever reason the LONG_CLICK (touch and hold) will not fire in the genymotion emulator. Single touches work fine.

It works fine with the mouse held down and on 7in China tablet.
 

sigster

Active Member
Licensed User
Longtime User
Hi

When I use this sample on my mobile the button is on the right side
but on my Tab the button is on the center bigger screen

how can I let the button be on the right side on Mobile or Tab

B4X:
p.AddView(b, 290dip, 2dip, 60dip, Height - 4dip) 'view #

Regards
Sigster
 

GMan

Well-Known Member
Licensed User
Longtime User
The Gravity parameter should solve this...
 
Status
Not open for further replies.
Top