Android Question CLV VisibleRangeChanged, how to add panel height

nickysuwandi

Member
Licensed User
Longtime User
Dear

I have try too using CLV VisibleRangeChanged, but i have some problem with panel height.
The panel item in CLV didn't load full page.

My code like this
Private Sub clvhistory_VisibleRangeChanged (FirstIndex As Int, LastIndex As Int)
For Each i As Int In Pclvhistory.VisibleRangeChanged(FirstIndex, LastIndex)
Dim item As CLVItem = clvhistory.GetRawListItem(i)
Dim pnl As B4XView = xui.CreatePanel("" )
'Dim pnl As Panel
item.Panel.AddView(pnl , 0, 0, item.Panel.Width, item.Panel.Height)
pnl.LoadLayout("pgmenuhistoryitem")
Dim ItemHistory1 As ItemHistory
ItemHistory1 =item.Value
lblmenuhistoryitem_no.Text =ItemHistory1.nobaris
Next
End Sub

I had try add height in panel height like this
item.Panel.AddView(pnl , 0, 0, item.Panel.Width, item.Panel.Height+200)
but this not make any change in my view

this the result
Capture.JPG


Anyone know how to solve this panel height problem?


Thanks

Nicky
 

nickysuwandi

Member
Licensed User
Longtime User
Please use [code]code here...[/code] tags when posting code.

Are you using PreoptimizedCLV? In most cases it is a mistake to use it.
Dear Erel

I had develop this apps under android 13, there no problem with panel height.

went i upgrade to android 13, this problem occurs.

but, i will try send the example here.

Thanks Erel for your quick response


Nicky
 
Upvote 0

nickysuwandi

Member
Licensed User
Longtime User
Please use [code]code here...[/code] tags when posting code.

Are you using PreoptimizedCLV? In most cases it is a mistake to use it.
Dear Erel

I have upload example code, i had try it on android under 13 (no problem with panel height), and android 13 (problem with panel height)
I don't know where is wrong from this code.

This is when running in android below 13

underandroid13.jpg


This when running in android 13
android13.jpg


Thanks

Nicky
 

Attachments

  • B4A.zip
    6.4 KB · Views: 63
Upvote 0

rraswisak

Active Member
Licensed User
Not tested since i don't have android 13, please try this...

B4X:
Private Sub clvhistory_VisibleRangeChanged (FirstIndex As Int, LastIndex As Int)
    For Each i As Int In Pclvhistory.VisibleRangeChanged(FirstIndex, LastIndex)
        Dim item As CLVItem = clvhistory.GetRawListItem(i)
        Dim pnl As B4XView = xui.CreatePanel("")
        pnl.LoadLayout("pgmenuhistoryitem") ' load layout first so we can get the view
        Dim v As B4XView = clvhistory.GetPanel(i).GetView(0) 'get panel view in the layout
        item.Panel.AddView(pnl , 0, 0, item.Panel.Width, v.Height + v.Top * 2) 'adjust he height base on panel height with space at top and bottom
        Dim ItemHistory1 As ItemHistory
        ItemHistory1 =item.Value
        lblmenuhistoryitem_no.Text =ItemHistory1.nobaris
        lblmenuhistoryitem_trno.Text =ItemHistory1.trno
    Next
End Sub
 
Upvote 0

nickysuwandi

Member
Licensed User
Longtime User
Not tested since i don't have android 13, please try this...

B4X:
Private Sub clvhistory_VisibleRangeChanged (FirstIndex As Int, LastIndex As Int)
    For Each i As Int In Pclvhistory.VisibleRangeChanged(FirstIndex, LastIndex)
        Dim item As CLVItem = clvhistory.GetRawListItem(i)
        Dim pnl As B4XView = xui.CreatePanel("")
        pnl.LoadLayout("pgmenuhistoryitem") ' load layout first so we can get the view
        Dim v As B4XView = clvhistory.GetPanel(i).GetView(0) 'get panel view in the layout
        item.Panel.AddView(pnl , 0, 0, item.Panel.Width, v.Height + v.Top * 2) 'adjust he height base on panel height with space at top and bottom
        Dim ItemHistory1 As ItemHistory
        ItemHistory1 =item.Value
        lblmenuhistoryitem_no.Text =ItemHistory1.nobaris
        lblmenuhistoryitem_trno.Text =ItemHistory1.trno
    Next
End Sub
Dear Rraswisak

error in line 6
 
Upvote 0

rraswisak

Active Member
Licensed User
Okay forget about my untested code above, i'm using PreoptimizesCLV on my InvitationTable, so i hope this will also work on android 13 too

Changes started from line 20 - 25
B4X:
Sub PTampilHistoryItem()
    Dim inthari As Int
    clvhistory.Clear
    Pclvhistory.Initialize(Me, "Pclvhistory", clvhistory)
    Try
        Dim strsql As String
        strsql="select trno from jual " 'count(produk)
        Dim Curs As Cursor
        Dim i,intbrsjual As Int
        Curs = SQL1.ExecQuery(strsql)
        Curs.Position = 0
        intbrsjual=0
        For i = 0 To Curs.RowCount - 1
            Curs.Position = i
            intbrsjual = intbrsjual+1
            Dim ItemHistory1 As ItemHistory
            ItemHistory1.nobaris=intbrsjual
            ItemHistory1.trno=Curs.GetString("trno")
          
            'Get actual height of layout for PreoptimizedCLV
            Dim pnl As B4XView = xui.CreatePanel("")
            pnl.LoadLayout("pgmenuhistoryitem")
            Dim height As Int = pnl.GetView(0).Height + pnl.GetView(0).Top * 2
          
            Pclvhistory.AddItem(height, xui.Color_White, ItemHistory1)
            'Pclvhistory.AddItem(110dip, xui.Color_White, ItemHistory1)
        Next
        Pclvhistory.Commit
        Curs.close
    Catch
        Log(LastException)
    End Try
End Sub

1671453715806.png
 
Last edited:
Upvote 0

nickysuwandi

Member
Licensed User
Longtime User
Okay forget about my untested code above, i'm using PreoptimizesCLV on my InvitationTable, so i hope this will also work on android 13 too

Changes started from line 20 - 25
B4X:
Sub PTampilHistoryItem()
    Dim inthari As Int
    clvhistory.Clear
    Pclvhistory.Initialize(Me, "Pclvhistory", clvhistory)
    Try
        Dim strsql As String
        strsql="select trno from jual " 'count(produk)
        Dim Curs As Cursor
        Dim i,intbrsjual As Int
        Curs = SQL1.ExecQuery(strsql)
        Curs.Position = 0
        intbrsjual=0
        For i = 0 To Curs.RowCount - 1
            Curs.Position = i
            intbrsjual = intbrsjual+1
            Dim ItemHistory1 As ItemHistory
            ItemHistory1.nobaris=intbrsjual
            ItemHistory1.trno=Curs.GetString("trno")
        
            'Get actual height of layout for PreoptimizedCLV
            Dim pnl As B4XView = xui.CreatePanel("")
            pnl.LoadLayout("pgmenuhistoryitem")
            Dim height As Int = pnl.GetView(0).Height + pnl.GetView(0).Top * 2
        
            Pclvhistory.AddItem(height, xui.Color_White, ItemHistory1)
            'Pclvhistory.AddItem(110dip, xui.Color_White, ItemHistory1)
        Next
        Pclvhistory.Commit
        Curs.close
    Catch
        Log(LastException)
    End Try
End Sub

View attachment 137087
Okay forget about my untested code above, i'm using PreoptimizesCLV on my InvitationTable, so i hope this will also work on android 13 too

Changes started from line 20 - 25
B4X:
Sub PTampilHistoryItem()
    Dim inthari As Int
    clvhistory.Clear
    Pclvhistory.Initialize(Me, "Pclvhistory", clvhistory)
    Try
        Dim strsql As String
        strsql="select trno from jual " 'count(produk)
        Dim Curs As Cursor
        Dim i,intbrsjual As Int
        Curs = SQL1.ExecQuery(strsql)
        Curs.Position = 0
        intbrsjual=0
        For i = 0 To Curs.RowCount - 1
            Curs.Position = i
            intbrsjual = intbrsjual+1
            Dim ItemHistory1 As ItemHistory
            ItemHistory1.nobaris=intbrsjual
            ItemHistory1.trno=Curs.GetString("trno")
         
            'Get actual height of layout for PreoptimizedCLV
            Dim pnl As B4XView = xui.CreatePanel("")
            pnl.LoadLayout("pgmenuhistoryitem")
            Dim height As Int = pnl.GetView(0).Height + pnl.GetView(0).Top * 2
         
            Pclvhistory.AddItem(height, xui.Color_White, ItemHistory1)
            'Pclvhistory.AddItem(110dip, xui.Color_White, ItemHistory1)
        Next
        Pclvhistory.Commit
        Curs.close
    Catch
        Log(LastException)
    End Try
End Sub

View attachment 137087

Thanks Rraswisak

I had try and i work perfectly. From your idea, i had changed this line

height panel:
Pclvhistory.AddItem(130dip, xui.Color_White, ItemHistory1)

and it work perfectly.
 
Upvote 0
Top