iOS Question Full screen view - customlistview problem

kisoft

Well-Known Member
Licensed User
Longtime User
Hi
In the application I use two modules of code, the main one and mod2. In both code modules I display a list (xcustolistview). When the user is in the main mode and clicks on the list item, the application moves him to the second module (mod2) and displays the second list... Everything works normally, but when I set it to full-screen view, the list in the second module is not built properly.

I did a small project project that shows a problem.

code main
B4X:
'Code module
#Region  Project Attributes
    #ApplicationLabel: Test
    #Version: 1.0.0
    'Orientation possible values: Portrait, LandscapeLeft, LandscapeRight and PortraitUpsideDown
    #iPhoneOrientations: Portrait, LandscapeLeft, LandscapeRight
    #iPadOrientations: Portrait, LandscapeLeft, LandscapeRight, PortraitUpsideDown
    #Target: iPhone, iPad
    #ATSEnabled: True
    #MinVersion: 8
    #PlistExtra: <key>UIViewControllerBasedStatusBarAppearance</key><false/>
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'Public variables can be accessed from all modules.
    Public App As Application
    Public NavControl As NavigationController
    Private Page1 As Page
    Public a0, a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16,a17,a18,a19,a20,a21 As String
    a0="Test1"
    a1="Test2"
    a2="Test3"
    a3="Test4"
    a4="Test5"
    a5="Test6"
    a6="Test7"
    a7="Test8"
    a8="Test9"
    a9="Test10"
    a10="Test11"
    a11="Test12"
    a12="Test13"
    a13="Test14"
    a14="Test15"
    a15="Test16"
    a16="Test17"
    a17="Test18"
    a18="Test19"
    a19="Test20"
    a20="Test21"
    a21="Test22"
    Private Panel1 As Panel
    Private Btn1 As Button
    Private CustomListView1 As CustomListView
    Dim nazwa As List
    Dim nazwa2 As String
    Private index As Int
    Public xui As XUI

    Private Label1 As Label
    Private Lab1 As Label
End Sub

Private Sub Application_Start (Nav As NavigationController)
    'SetDebugAutoFlushLogs(True) 'Uncomment if program crashes before all logs are printed.
    NavControl = Nav
    Dim no As NativeObject = App
    no.RunMethod("setStatusBarHidden:animated:", Array(True, False))
    NavControl.NavigationBarVisible =  False
    Page1.Initialize("Page1")
    Page1.RootPanel.LoadLayout("1")
'    Page1.Title = "Page 1"
   Lab1.Text= "Main"
    resetmain
    NavControl.ShowPage(Page1)
    
    nazwa.Initialize
    For Each f As String In Array(a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16,a17,a18,a19,a20,a21)
        nazwa.Add(f)
    Next
    
    For i = 0 To 21
        CustomListView1.Add(CreateListItem(100%x,7%y),i)
        nazwa2=nazwa.get(i)
        Label1.Text=nazwa2
    Next
    
End Sub

Sub resetmain
    NavControl.ShowPage(Page1)
    
End Sub


Sub CreateListItem(Width As Int, Height As Int) As Panel
    Dim p As B4XView = xui.CreatePanel("")
    p.SetLayoutAnimated(0, 0, 0, Width, Height)
    p.LoadLayout("2")
    Return p
    
End Sub


Private Sub Page1_Resize(Width As Int, Height As Int)
    
End Sub

Private Sub Application_Background
    
End Sub


Sub Btn1_Click
    
End Sub

Sub Label1_Click
    index=CustomListView1.GetItemFromView(Sender)
    Log("main indeks="&index)
    mod2.Show
End Sub

code mod2
B4X:
'Code module

Sub Process_Globals
    Private Pg As Page
    Public a0, a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16,a17,a18,a19,a20,a21 As String
    a0="Test1a"
    a1="Test2a"
    a2="Test3a"
    a3="Test4a"
    a4="Test5a"
    a5="Test6a"
    a6="Test7a"
    a7="Test8a"
    a8="Test9a"
    a9="Test10a"
    a10="Test11a"
    a11="Test12a"
    a12="Test13a"
    a13="Test14a"
    a14="Test15a"
    a15="Test16a"
    a16="Test17a"
    a17="Test18a"
    a18="Test19a"
    a19="Test20a"
    a20="Test21a"
    a21="Test22a"
    Private Panel1 As Panel
    Private Btn1 As Button
    Private CustomListView1 As CustomListView
    Dim nazwa As List
    Dim nazwa2 As String
    Private index As Int
    Public xui As XUI
    Private label1 As Label
    Private Lab1 As Label
End Sub

Public Sub Show
    
    If Pg.IsInitialized = False Then
        Main.NavControl.NavigationBarVisible =  False
        Pg.Initialize("pg")
'    pg.RootPanel.RemoveAllViews
        Pg.RootPanel.LoadLayout("1")
        Lab1.Text= "Mod2"
        Main.NavControl.ShowPage(Pg)
    End If
    nazwa.Initialize
    For Each f As String In Array(a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16,a17,a18,a19,a20,a21)
        nazwa.Add(f)
    Next
    
    For i = 0 To 21
        CustomListView1.Add(CreateListItem(100%x,7%y),i)
        nazwa2=nazwa.get(i)
        label1.Text=nazwa2
    Next
End Sub Sub

Sub CreateListItem(Width As Int, Height As Int) As Panel
    Dim p As B4XView = xui.CreatePanel("")
    p.SetLayoutAnimated(0, 0, 0, Width, Height)
    p.LoadLayout("2")
    Return p   
End Sub

Sub Label1_Click
    index=CustomListView1.GetItemFromView(Sender)
    Log("main indeks="&index)   
End Sub

Sub Btn1_Click
    Main.resetmain
End Sub
 

Attachments

  • file.zip
    76.7 KB · Views: 246
  • IMG_2218.PNG
    IMG_2218.PNG
    94.9 KB · Views: 249
  • IMG_2219.PNG
    IMG_2219.PNG
    281.8 KB · Views: 257
D

Deleted member 103

Guest
Try like this:
B4X:
Public Sub Show
    
    'If Pg.IsInitialized = False Then
        Main.NavControl.NavigationBarVisible =  False
        Pg.Initialize("pg")
'    pg.RootPanel.RemoveAllViews
        Pg.RootPanel.LoadLayout("1")
        Lab1.Text= "Mod2"
        Main.NavControl.ShowPage(Pg)
    'End If
    nazwa.Initialize
    For Each f As String In Array(a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16,a17,a18,a19,a20,a21)
        nazwa.Add(f)
    Next
    
    For i = 0 To 21
        CustomListView1.Add(CreateListItem(100%x,7%y),i)
        nazwa2=nazwa.get(i)
        label1.Text=nazwa2
    Next
End Sub Sub
 
Upvote 0
D

Deleted member 103

Guest
move the code to pg_resize.
B4X:
Sub pg_resize(Width As Int, Height As Int)
   For i = 0 To 21
        CustomListView1.Add(CreateListItem(100%x,7%y),i)
        nazwa2=nazwa.get(i)
        label1.Text=nazwa2
    Next
End Sub
 
Upvote 0
Top