Android Question Any view pressed ?

Devv

Active Member
Licensed User
Longtime User
I have a listview is want to close it if the user touched anywhere outside the listview

the typical way is adding this to all other elements
B4X:
if listview1.visable = true then listview1.visable = false

but i have lots of elements how can i achieve that in another way ?
 

Mahares

Expert
Licensed User
Longtime User
but i have lots of elements how can i achieve that in another way ?
How about using the Activity or parent click event like this:
B4X:
Private lv As ListView
lv.Initialize("lv")
    Activity.AddView(lv,0,0,50%x,35%y)
    lv.AddSingleLine("Erel")
    lv.AddSingleLine("klaus")
    lv.AddSingleLine("DonManfred")

B4X:
Sub Activity_Click
    If lv.Visible=True Then
        lv.Visible=False
    Else
        lv.Visible=True
    End If
End Sub
 
Upvote 0

Devv

Active Member
Licensed User
Longtime User
How about using the Activity or parent click event like this:
B4X:
Private lv As ListView
lv.Initialize("lv")
    Activity.AddView(lv,0,0,50%x,35%y)
    lv.AddSingleLine("Erel")
    lv.AddSingleLine("klaus")
    lv.AddSingleLine("DonManfred")

B4X:
Sub Activity_Click
    If lv.Visible=True Then
        lv.Visible=False
    Else
        lv.Visible=True
    End If
End Sub


thanks for replay
but it did not worked for me
nothing triggers Activity_Click

any idea why ?
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
but it did not worked for me
nothing triggers Activity_Click

I tested it before posting and it worked for me just fine: Here is the complete project. Just paste it in a new project and test for yourself:
B4X:
Sub Globals
    Private lv As ListView
End Sub

Sub Activity_Create(FirstTime As Boolean)   
    lv.Initialize("lv")
    Activity.AddView(lv,0,0,50%x,35%y)
    lv.AddSingleLine("Erel")
    lv.AddSingleLine("klaus")
    lv.AddSingleLine("DonManfred")
End Sub

Sub Activity_Click
    If lv.Visible=True Then
        lv.Visible=False
    Else
        lv.Visible=True
    End If
End Sub
 
Upvote 0

sorex

Expert
Licensed User
Longtime User
put the stuff that needs to be hidden in a seperate panel and just hide the panel.
 
Upvote 0
Top