Android Question [SOLVED] ListView inside a Panel not responding to finger scroll on Android 8.0.0

Papou

New Member
Licensed User
Hi,

I have an issue when I create a ListView inside a Panel on Android 8.0.0 : The listview is not responding to any finger scroll but Item Click is working well.

I tried this code on Android 4.4 and it is working well.

Can you help me ?

Thank you

Papou

B4X:
#Region  Project Attributes
    #ApplicationLabel: B4A Example
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

    Private pnLog As Panel
    Private lvLog As ListView
    Private lbText As Label
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    
    lbText.Initialize("lbText")
    lbText.Color=Colors.Cyan
    Activity.AddView(lbText,0,0,100%x,10%y)
    
    pnLog.Initialize("pnLog")
    pnLog.Elevation=8dip
    pnLog.Color=Colors.red
    Activity.AddView(pnLog,0,0,100%x,30%y)
    
    lvLog.Initialize("lvLog")
    pnLog.AddView(lvLog,0,0,100%x,100%y)
    pnLog.Visible=False
    create_lvLog
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub
Sub create_lvLog
    Dim label1 As Label
    label1 = lvLog.SingleLineLayout.Label
    label1.TextSize = 20
    For i=0 To 10
        lvLog.AddSingleLine("Message #"&i)
    Next
    
End Sub

Sub lbText_Click
    pnLog.Visible=Not(pnLog.Visible)
End Sub

Sub lvLog_ItemClick (Position As Int, Value As Object)
    pnLog.Visible=False
    lbText.Text=Value
End Sub
 

Star-Dust

Expert
Licensed User
Longtime User
Correct this
B4X:
pnLog.AddView(lvLog,0,0,100%x,30%y)
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
This is wrong too:
Activity.AddView(lbText, 0, 0, 100%x, 10%y)
Activity.AddView(pnLog, 0, 0, 100%x, 30%y)

pnLog will overlap lbText !
Activity.AddView(lbText, 0, 0, 100%x, 10%y)
Activity.AddView(pnLog, 0, 10%y, 100%x, 30%y)


Instead of
pnLog.AddView(lvLog, 0, 0, 100%x, 30%y)
I would use
pnLog.AddView(lvLog, 0, 0, pnLog.Width, pnLog.Height)
 
Upvote 0

Papou

New Member
Licensed User
[SOLVED]
Thank you very much Stat-Dust and Klaus for your remarks:

The problem was effectively the pnLog.AddView(lvLog,0,0,100%x,100%y) as I was thinking that the child will have %x & %y fully sizing the Parent view. It is not the case (which is not very intuitive and the remark of Klaus take in this case full sense: It is better to use Parent.AddView(Child,0,0,%*Parent.Width, %*Parent.Height) than absolute value)

@Star-Dust:
pnLog will overlap lbText : It was on purpose as the idea was to do a dropdown list with the Label showing the selected element.


Thank you again

Have all a nice day

P.
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…