Android Question Click event of a panel not working

Mike1970

Well-Known Member
Licensed User
Longtime User
Hi everyone,
I have a Panel with insisde a Scrollview that fills the panel.
I wish to handle the Click event of the panel, but it is not working, nothing happen when i click something where the scrollview is present. like if the the scrollview is acting as a shield between me and the panel.

How can i bypass this thing?
Thanks in advance
 

Situ LLC

Active Member
Licensed User
Click:
Private Sub LoadClv
        
    Dim bview As B4XView = xui.CreatePanel("")
    bview.SetLayoutAnimated(100,0,0,100%x,190dip)
    bview.LoadLayout("Lyt_Clv")
    bview.Color = xui.Color_Transparent
    Label1.Text=  " 1  Ecoja Parada a viajar "
    Label2.Text=  " PARADAS"
    Label3.Text=  "Pulse en el recuado y escoja la parada donde desea viajar ahora"
    ImageView1.Bitmap    = LoadBitmap(File.DirAssets,"lista.png")   
    ImageView2.Bitmap    = LoadBitmap(File.DirAssets,"1.png")
    
    Clv.Add(bview,1)
        
    Dim bview As B4XView = xui.CreatePanel("")
    bview.SetLayoutAnimated(100,0,0,100%x,190dip)
    bview.LoadLayout("Lyt_Clv")
    bview.Color = xui.Color_Transparent
    Label1.Text=  " 2  Ecoja Proximo horario disponible "
    Label2.Text=  "HORARIOS"
    Label3.Text=  "Pulse aqui para escojer el horario que desea viajar "
    ImageView1.Bitmap    = LoadBitmap(File.DirAssets,"eh.png")
    ImageView2.Bitmap    = LoadBitmap(File.DirAssets,"2.png")
    
    Clv.Add(bview,2) 
    
    Dim bview As B4XView = xui.CreatePanel("")
    bview.SetLayoutAnimated(50,0,0,100%x,370dip)
    bview.LoadLayout("Pagar")
    bview.Color = xui.Color_Transparent
    Label1lvc.Text=  " Falta Información del billete "
    
    Clv.Add(bview,3)
    
    Dim bview As B4XView = xui.CreatePanel("")
    bview.SetLayoutAnimated(100,0,0,100%x,210dip)
    bview.LoadLayout("info")
    bview.Color = xui.Color_Transparent
    Labelpago.Text =  "Información de pago "
    EditText1.Text = "codigos"
    Clv.Add(bview,4)
    
    Dim jo As JavaObject = Clv.sv
    jo.RunMethod("setVerticalScrollBarEnabled", Array(False))
    
    ShowScrollbar(Clv.sv)
End Sub

Sub ShowScrollbar(ScrollView1 As ScrollView)
    Dim jo = ScrollView1 As JavaObject
    jo.RunMethod("setScrollBarFadeDuration", Array As Object (14000))
End Sub



Private Sub clv_ItemClick (Index As Int, Value As Object)
 
    Dim escojido  As Int  = Value
    
'    Log( "Opcion escojida  "& Value)
    
    Clv.AsView.BringToFront
    
    If escojido ="1 Then
'        B4XPages.ShowPage("tarifa")
    End If
    
    
    If escojido ="2" Then
        B4XPages.ClosePage(Me)
    End If
    
    If escojido ="3" Then
    
        B4XPages.ShowPage("Horario")
        
    End If

    If escojido ="1" Then
    
        B4XPages.ShowPage("Parada")
        
    End If

        
    
End Sub
 
Upvote 0

Situ LLC

Active Member
Licensed User
Mike just take a look

Private Sub clv_ItemClick (Index As Int, Value As Object)

Dim escojido As Int = Value

' Log( "click the option -----> "& Value)

' value came from each add

' Clv.Add(bview,1)
' Clv.Add(bview,2)
'Clv.Add(bview,3)


Clv.AsView.BringToFront

If escojido ="1 Then
' B4XPages.ShowPage("tarifa")
End If


Enjoy ...
 
Upvote 0

Mike1970

Well-Known Member
Licensed User
Longtime User
Mike just take a look

Private Sub clv_ItemClick (Index As Int, Value As Object)

Dim escojido As Int = Value

' Log( "click the option -----> "& Value)

' value came from each add

' Clv.Add(bview,1)
' Clv.Add(bview,2)
'Clv.Add(bview,3)


Clv.AsView.BringToFront

If escojido ="1 Then
' B4XPages.ShowPage("tarifa")
End If


Enjoy ...
Thanks for the reply, but I don't think its my case.

A blueprint could be this:

B4X:
Private p as Panel
Private s as ScrollView

B4X:
Sub Activity_Create(FirstTime As Boolean)
  Activity.LoadLayout("layout") 'Here there are the "p" with inside it "s"
End Sub

Sub p_Click
  Log("Clicked") 'Not working' if i click on "s" that covers all the panel "p"
End Sub
 
Upvote 0

Mike1970

Well-Known Member
Licensed User
Longtime User
The ScrollView will consume the touch events. The only way around it is to use ViewsEx with TouchPanelCreator. You will need to handle the touch logic yourself and it can be a bit complicated.
o_O Ok, i will do without
Thanks Erel
 
Upvote 0
Top