Android Question how can i unload layout ?

Waldemar Lima

Well-Known Member
Licensed User
hi everyone !

how can i unload layout without "Re"load back side ?


like this screenshot >
this buttons are loades on "front" of Gmaps , how can i unload this buttons layout without reload gmaps layout ?

http://prntscr.com/ib0ys3
 

Waldemar Lima

Well-Known Member
Licensed User
this dont works :c

B4X:
Sub Globals
    Private gmap As GoogleMap
    Private MapFragment1 As MapFragment
    Private Button1 As Button
    Private Button2_n As Button
    Private Button3_n As Button
    Private Button4_n As Button
    Private bmp As Bitmap
    Private cp As CameraPosition
    Private MenuIsVisible As Int
    
End Sub

Sub Button1_click
    Button2_n.Visible = True ' error = -- java.lang.RuntimeException: Object should first be initialized (Button).
End Sub

Sub Button2_n_click

End Sub

Sub Button3_n_click

End Sub

Sub Button4_n_click

End Sub


Sub Activity_Create(FirstTime As Boolean)
    
    bmp = LoadBitmapResize(File.DirAssets, "bus_stop_point.png", 32dip, 32dip, True)
    Activity.LoadLayout("1")
    
    If MapFragment1.IsGooglePlayServicesAvailable = False Then
        ToastMessageShow("Please install Google Play Services.", True)
    End If
    Dim width = Activity.Width
    Dim height = Activity.Height
    
    Log("width = "&width)
    Log("height = "&height)
End Sub
 
Upvote 0

Waldemar Lima

Well-Known Member
Licensed User
like this >

B4X:
Sub Globals
    Private gmap As GoogleMap
    Private MapFragment1 As MapFragment
    Private Button1 As Button
    Private Button2_n As Button
    Private Button3_n As Button
    Private Button4_n As Button
    Private bmp As Bitmap
    Private cp As CameraPosition
    Private MenuIsVisible As Int
    
End Sub


Sub Activity_Create(FirstTime As Boolean)
    
    bmp = LoadBitmapResize(File.DirAssets, "bus_stop_point.png", 32dip, 32dip, True)
    Activity.LoadLayout("1")
    
    Do While Activity.IsInitialized = False
        Sleep(100)
    Loop
    
    If MapFragment1.IsGooglePlayServicesAvailable = False Then
        ToastMessageShow("Please install Google Play Services.", True)
    End If
    Dim width = Activity.Width
    Dim height = Activity.Height
    
    Log("width = "&width)
    Log("height = "&height)
End Sub

Sub Button1_click

    Button2_n.Visible = True
End Sub

Sub Button2_n_click

End Sub

Sub Button3_n_click

End Sub

Sub Button4_n_click

End Sub
 
Upvote 0

Jeffrey Cameron

Well-Known Member
Licensed User
Longtime User
I'm pretty sure the order of the procedures in the code is irrelevant (aesthetics aside). What is relevant, is that you're certain that the "Button2_n" name you've given the button in Globals is the same name you have specified in your "1.bal" file?
 
Upvote 0

Jeffrey Cameron

Well-Known Member
Licensed User
Longtime User
Additionally, if you have multiple buttons you wish show/hide at the same time, I would recommend creating a panel and adding the panel to the activity. Then you can put the UI layout inside the panel and show/hide the entire panel at once rather than doing each individual button.
 
Upvote 0
Top