Android Question [SOLVED] - POSSIBLE BUG? Custom List View Layout in Horizontal Scrolling

JMB

Active Member
Licensed User
Longtime User
I've got a custom List view into which I load panels which look absolutely fine when I am using the list view in vertical scroll mode.

However, when I change to horizontal scroll mode, the width of the panels change to be about 1.5 times the width of the screen.

I've got code which sets the width of the panel to the width of the Custom List view -
B4X:
newCellPanel.SetLayoutAnimated(10, 0, 0, clvSectorList.AsView.Width, Height)

and I have a variant in the Layout designer which matches the size of the device I am using but it still creates a panel which is too wide when in horizontal scroll mode.

Does anyone have any suggestions as to how to fix this?

Thank you.

JMB
 

JMB

Active Member
Licensed User
Longtime User
Hi - sorry for the long delay in replying to this.

I have narrowed down the problem, and I am wondering if it is a bug.

When I create a panel, I make it the width of the CustomListView into which it will go. That works absoutely fine.

I create a panel and then add the panel using this:

B4X:
NewSectorCell = CreateASectorPanel(NewSectorNumber, clvSectorList.AsView.Width, CellHeight)
clvSectorList.Add(NewSectorCell, Waypoint)

This works fine - the width of the panel is correct and horizontal scrolling works as expected.

However, when changes are made to the contents of that panel at a particular index in the custom list, I use ReplaceAt to put a new panel in with all the updated information.

That's the point at which the width goes awry.

Here's the code to give you an idea...

First there is a call to create a new panel using the width of the customlist view.
Then there is call to put the new panel (cell as I call it) into the Custom List.

Note that the ReplaceAt only allows the setting of the height, not the width

B4X:
NewSectorCell = CreateASectorPanel(i, clvSectorList.AsView.Width, CellHeight)
clvSectorList.ReplaceAt(i,NewSectorCell,CellHeight,DestinationWaypoint)

Why does replacing an item with what is essentially exactly the same size of panel result in the width being too great?

Is that a bug?

Thanks for your help.

JMB
 
Upvote 0

JMB

Active Member
Licensed User
Longtime User
ok... completely mystified now. I stripped down the code to create a small program... and it works.

But it still doesn't work in the bigger version, so I am virtually taking out stuff line by line to try and figure out what's going on as the core sub-routines are pretty much identical.

Will keep looking.

JMB
 
Upvote 0

JMB

Active Member
Licensed User
Longtime User
Ok, I've managed to recreate the problem with the smaller program.

Click on the green plus sign to add a panel. It is set to horizontal scroll.

If you comment out line 169 - the REPLACEAT call - the display works correctly (the widths of each cell are correct)

The problem is that it will only show the old panels and I need to be able to replace the panels in the list because the data in each panel changes when the user selects options etc.

If you allow line 169 to work - you will see that the first cell added is correct - because that function doesn't get called - but after that, the width goes awry.

I've stripped out as much of the code and left the bare bones of the display functionality in there.

Your help is much appreciated... I've got no idea why the REPLACEAT seems to change the width of the panel.

JMB
 

Attachments

  • DEMO OF POSSIBLE CLV BUG.zip
    118.2 KB · Views: 168
Upvote 0

rraswisak

Active Member
Licensed User
Try to replace
B4X:
clvSectorList.ReplaceAt(i,NewSectorCell,CellHeight,Null)

with this one
B4X:
clvSectorList.RemoveAt(i)
clvSectorList.InsertAt(i,NewSectorCell,Null)

the REPLACEAT seems to change the width of the panel
and yes the question still remain
 
Last edited:
  • Like
Reactions: JMB
Upvote 0

JMB

Active Member
Licensed User
Longtime User
Gentlemen,

Thank you both for your help with this. I have solved the problem by doing what rrawwisak suggested - remove then insert, rather than replace.

That makes the problem go away.

Using replace makes the poblem reappear.

I will post some screenshots for you Erel to show you what I mean.

Thanks again.

JMB
 
Upvote 0

JMB

Active Member
Licensed User
Longtime User
This is what is happening. This first shows a full cell in the Custom list View.

CLV-1.jpg


This shows how the scroll right works - there's a second cell, and there's no gap between the cells as you would expect.

This was achieved using
B4X:
clvSectorList.RemoveAt(i)
clvSectorList.InsertAt(i,NewSectorCell,Null)

CLV-2.jpg


However, if you use ReplaceAt you get the following:


CLV-3.jpg



Note the big gap between the two panels.

This seems to be a bug because the RemoveAt then InsertAt way of doing things works.

JMB
 

Attachments

  • CLV-1.jpg
    CLV-1.jpg
    111.8 KB · Views: 126
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
I understand.

I've updated ReplaceAt signature and documentation:
B4X:
'Replaces the item at the specified index with a new item.
'ItemSize - Item's height for vertical orientation and width for horizontal orientation.
Public Sub ReplaceAt(Index As Int, pnl As B4XView, ItemSize As Int, Value As Object)

Previously it was named ItemHeight which is only correct in the case of vertical orientation.
 
  • Like
Reactions: JMB
Upvote 0
Top