Android Question CustomListView anomolies

Roger Daley

Well-Known Member
Licensed User
Longtime User
Hi All,

Still on learning curve for CLV I've struck a couple of oddities.

1. in the code below [using Loadlayout] if I include the lines [3&4 commented out] to align sv with CLV I have no items displayed. ???
With these two lines commented out all works well.

Menu:
Sub Menu
    ListFlag = 1

    'Change CustomListView from default to the Menu Size/Position
    AllListView.getbase.Height = 200dip                                    'Sets height and top position of CLV
    AllListView.getbase.Top = 100%y -AllListView.getbase.Height
'    AllListView.sv.Height = AllListView.getbase.Height                    'Sets sv to match CLV
'    AllListView.sv.Top = AllListView.getbase.Top
'   
    
    AllListTitle.Top = AllListView.GetBase.Top - AllListTitle.Height    'Set title label at top of CLV
    AllListBack.Top = AllListTitle.Top                                    'Sets back button at top of CLV
    AllListTitle.Text = "MENU"
    AllListBack.Text = "<<<"
    AllListClear.Visible = False                                        'Hides clear button
    AllListClear.Enabled = False
    
    'Sets CLV as MENU)
    AllListView.Clear                'Clear CLV before populating or else you get duplicates
    
    'Load 5 items.  Yes a loop would look better but ........

    Public ALVitem As B4XView = XUI.createpanel("")
    ALVitem.SetLayoutAnimated(100,0,0,100%x,40dip)
    ALVitem.LoadLayout("CLVmenu")                                        'Loads layout from designer [One label 100%x * 40]
    lblMenuItem.Text = "ABOUT"
    lblMenuItem.Height = ALVitem.Height
    AllListView.Add(ALVitem,0)
    
    Public ALVitem As B4XView = XUI.createpanel("")
    ALVitem.SetLayoutAnimated(100,0,0,100%x,40dip)
    ALVitem.LoadLayout("CLVmenu")
    lblMenuItem.Text = "HELP"
    lblMenuItem.Height = ALVitem.Height
    AllListView.Add(ALVitem,0)
    
    Public ALVitem As B4XView = XUI.createpanel("")
    ALVitem.SetLayoutAnimated(100,0,0,100%x,40dip)
    ALVitem.LoadLayout("CLVmenu")
    lblMenuItem.Text = "SETTINGS"
    lblMenuItem.Height = ALVitem.Height
    AllListView.Add(ALVitem,0)
    
    Public ALVitem As B4XView = XUI.createpanel("")
    ALVitem.SetLayoutAnimated(100,0,0,100%x,40dip)
    ALVitem.LoadLayout("CLVmenu")
    lblMenuItem.Text = "EXPORT FUNCTION"
    lblMenuItem.Height = ALVitem.Height
    AllListView.Add(ALVitem,0)
                    
    Public ALVitem As B4XView = XUI.createpanel("")
    ALVitem.SetLayoutAnimated(100,0,0,100%x,40dip)
    ALVitem.LoadLayout("CLVmenu")
    lblMenuItem.Text = "IMPORT FUNCTION"
    lblMenuItem.Height = ALVitem.Height
    AllListView.Add(ALVitem,0)
    
    PnlAllListView.Elevation = 4dip
End Sub

2. With the code below [ using CLV.AddTextItem ] if I don't include the lines to align sv with CLV only the first 5 items are displayed until I scroll down. ???
If I include the lines to align sv with CLV all 7 items are displayed but there is a space of about 1 item between the Title and the first item.

I can get around the enigma but the fact that these oddities are there tells me I am doing something wrong.

Is there a smart person out there who knows the answer/s.

Regards Roger.
 

Roger Daley

Well-Known Member
Licensed User
Longtime User
Erel, Et Al

As requested. Sample code attached, in this example I can't get the situation where only 5 of the 7 SETTINGS items are shown but the space at the top is.
In the MENU list, when the lines to align the sv and CLV no items appear.

Regards Roger
 

Attachments

  • SimpleLV.zip
    11.8 KB · Views: 124
Upvote 0

rraswisak

Active Member
Licensed User
Longtime User
Usually if i want to acces xCustomListView dimenension (Width, Height) or position (Top, Left), all i have to do is call CustomListview1.AsView...
B4X:
CustomListview1.AsView.Height = 120dip
CustomListview1.AsView.Width = 100%x
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
The sooner you switch to B4XPages, the sooner things will be much simpler.

I would have used B4XDialog + B4XListTemplate here.

I don't understand the problem. I click on settings and see:

1599719068560.png
 
Upvote 0

Roger Daley

Well-Known Member
Licensed User
Longtime User
Usually if i want to acces xCustomListView dimenension (Width, Height) or position (Top, Left), all i have to do is call CustomListview1.AsView...
B4X:
CustomListview1.AsView.Height = 120dip
CustomListview1.AsView.Width = 100%x

rraswisak, gave it a try but no difference.
The sooner you switch to B4XPages, the sooner things will be much simpler.

I would have used B4XDialog + B4XListTemplate here.

I don't understand the problem. I click on settings and see:

View attachment 99870
The sooner you switch to B4XPages, the sooner things will be much simpler.

I would have used B4XDialog + B4XListTemplate here.

I don't understand the problem. I click on settings and see:

View attachment 99870


Erel,

Was this with or without the two lines included?
B4X:
AllListView.sv.Height = AllListView.GetBase.Height
    AllListView.sv.Top = AllListView.getbase.Top

As I described in the first post. I am getting slightly different results in the example code from the real code. Who knows, I will keep plodding on.

It's a funny world sometimes.

Some time ago:
ME: Ask question on forum.
EREL: You should learn to use anchors and you code is too messy to debug.
ME: Correct, stuck in beginners guide. Take an early App and search for ways to do things better.
ME: Ask question on forum about listview.
EREL: Forget Listview use CustomListView.
ME: CLV does have lots more. Scrap Listview
ME: Ask question on forum about CLV
EREL: You will find things simpler using B4XPages.
ME: Finish getting 13 lists working with CLV in old App then look at B4XPages [Whatever the hell that is]
ME: With my learning speed these days by the time I get on top of B4XPages it will be redundant.

ME: Trying to catch up.

Head.jpg


Regards Roger
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Everything still works exactly as before. You can use ListView. You don't need to use anchors.
As sometimes happen, there are improvements and new ways to do things that are actually simple. There is never a new feature that is not helpful in some way. It doesn't mean that you should use all new features.

B4XPages makes B4A development simpler. In many cases much simpler.
 
Upvote 0

Roger Daley

Well-Known Member
Licensed User
Longtime User
Everything still works exactly as before. You can use ListView. You don't need to use anchors.
As sometimes happen, there are improvements and new ways to do things that are actually simple. There is never a new feature that is not helpful in some way. It doesn't mean that you should use all new features.

B4XPages makes B4A development simpler. In many cases much simpler.

All good, I like CLV and I think [maybe] the space I'm getting relates to sv and CLV not aligning by the height of the title label. I will keep trying to find out how I did it. ?
 
Upvote 0
Top