Android Question Set activity background Image from gallery

SMOOTSARA

Active Member
Licensed User
Longtime User
Hello dear friends 🌹

I want to change the background activity

How can I select and set photo from the phone gallery by pressing Button4?


1613809340332.png

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.
    Private Button1 As Button
    Private Button2 As Button
    Private Button3 As Button
    Private Button4 As Button
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("Layout")
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub Button1_Click
    Activity.SetBackgroundImage(LoadBitmap(File.DirAssets, "background1.jpg"))
End Sub

Private Sub Button3_Click
    Activity.SetBackgroundImage(LoadBitmap(File.DirAssets, "background3.png"))
End Sub

Private Sub Button2_Click
    Activity.SetBackgroundImage(LoadBitmap(File.DirAssets, "background2.png"))
End Sub


Private Sub Button4_Click
    
End Sub
 

DonManfred

Expert
Licensed User
Longtime User
I did found an example in less than 1 Minute using the Forumsearch.

 
Upvote 0

Andrew (Digitwell)

Well-Known Member
Licensed User
Longtime User
You use the Content Chooser.
There are lots of examples on the forum


 
Upvote 0
Top