Android Question How to set Icon in B4A,B4i and B4J as B4XPages

Theera

Well-Known Member
Licensed User
Longtime User
I have tested creating B4XPages,but I don't know Coding to set png file as Icon in B4A,B4i and B4J,I need to code in my b4xtemplate.
 

Peter Simpson

Expert
Licensed User
Longtime User
Hello @Theera,
The app icon has to be set natively.
I don't know Coding to set png file as Icon

B4A and B4i: The usual ways

B4J:
B4X:
     B4XPages.GetNativeParent(Me).Icon = XUI.LoadBitmap(File.DirAssets, "YourIcon.png")


Enjoy...
 
Last edited:
Upvote 1

Theera

Well-Known Member
Licensed User
Longtime User
Hello @Theera,
The app icon has to be set natively.


B4A and B4i: The usual ways

B4J:
B4X:
     B4XPages.GetNativeParent(Me).Icon = XUI.LoadBitmap(File.DirAssets, "YourIcon.png")


Enjoy...
I have changed some code for supported all,but I don't know how can I refer to %PROJECT_NAME% is right,or not. please help to code. (using b4xtemplate)
B4X:
#If B4J
       xui.SetDataFolder(%PROJECT_NAME%)
    #End If
    If File.Exists(xui.DefaultFolder,"YourIcon.png")=False Then
        File.Copy(File.DirAssets, "YourIcon.png",xui.DefaultFolder,"YourIcon.png")
    End If
  
    B4XPages.GetNativeParent(Me).Icon = xui.LoadBitmap(xui.DefaultFolder, "YourIcon.png")
 
Upvote 0

Peter Simpson

Expert
Licensed User
Longtime User
???

You just need to to add your app icon to the assets folder then...
B4X:
     #If B4J
          B4XPages.GetNativeParent(Me).Icon = XUI.LoadBitmap(File.DirAssets, "YourIcon.png")
     #End If

Your app is now showing your app icon on the taskbar and app...
 
Upvote 0

Theera

Well-Known Member
Licensed User
Longtime User
???

You just need to to add your app icon to the assets folder then...
B4X:
     #If B4J
          B4XPages.GetNativeParent(Me).Icon = XUI.LoadBitmap(File.DirAssets, "YourIcon.png")
     #End If

Your app is now showing your app icon on the taskbar and app...
I 've saved YourIcon.png in Shared Files folder,and then I use Ctrl+Click each platform. I wonder in B4A and B4i , why we don't code for them.
 
Upvote 0

Theera

Well-Known Member
Licensed User
Longtime User
Hi Peter,
I get understand your thinking,in B4A and in B4i ,they can created icon for apps themselves ,but in B4J can't do. In another hand,I would like to create the apps by using the same Icon.
 
Upvote 0
Top