iOS Question CustomListView size

Haris Hafeez

Active Member
Licensed User
Longtime User
Hello All,

I am left quite puzzled with CLV's behaviour.

In one of my modules, the page has a CLV in which I add custom panels in code. This panel loads a layout and it works as expected in the CLV.

In another of my modules, I have a CLV in which I simply add text (using AddTextItem). As seen in the code fragment below, I want the CLV to take up the entire page's screen. The first time the page containing this is shown, the CLV works as expected. However, the next time this page is shown, the CLV shrinks in size to less than half the one it takes up when shown the first time. I have really got exhausted and will probably go to sleep thinking what is causing this.

I will really appreciate if someone can point out how to best use CLV so it always takes up the available screen size. The module that is causing the issue is below:

B4X:
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'Public variables can be accessed from all modules.
    Public pg As Page
    Public DraftsListView As CustomListView
End Sub

Sub Show
    If Not(pg.IsInitialized) Then
        DraftsListView.Initialize(Me, "DraftsListView", 100%x)
        pg.Initialize("page")
        'this is an empty layout with just the title set
        'i have also tried to not use this layout at all but doesnt make a difference
        pg.RootPanel.LoadLayout("AvailableDrafts")
    End If
    Main.NavControl.ShowPage(pg)
End Sub

.....
'this sub is called from the main page on an event
Sub LoadDraftsInListView
'i have moved the first two lines here because this is when i at least 
'get the CLV to take up correct size the first time. originally i just placed the AddView
'in the initialization above and didn't use RemoveAllViews at all
'but that always resulted in a small CLV
    pg.RootPanel.RemoveAllViews
    pg.RootPanel.AddView(DraftsListView.AsView,0,0,100%x,100%y)
    DraftsListView.Clear
    For Each key As String In DraftsList.Keys
        Dim msg As DraftMessage = DraftsList.Get(key)
        DraftsListView.AddTextItem("To: " & msg.MsgTo & " - Subject: " & msg.MsgSubject, key)
    Next
End Sub
 
Top