Android Question Use extrernal layout

udg

Expert
Licensed User
Longtime User
Hi,
I'm not sure to fully understand your question. As you know we have LoadLayout to load a layout designed in the Internal Designer. So you could prepare more than one alternative for a specific Activity and then load the desidered one based on code, settings, whatever.
By "external" do you mean available on a server of yours? In that case, yes, you could download it and make it active by LoadLayout. A key point will be that all the alternative layouts should sport objects named in the same way and your Activity's code should know about them.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
In that case, yes, you could download it and make it active by LoadLayout
How do you archieve that? LoadLayout will load the layout from the Files folder which is, for the running app, readonly.
 
Upvote 0

udg

Expert
Licensed User
Longtime User
Never tried, but it seems that nothing in the doc specifies that the .bal should be necessarily contained in the Assets directory. Maybe passing a string like File.DirInternal+bal_file. I have to try..
 
Upvote 0

devmobile

Active Member
Licensed User
Hi,
I'm not sure to fully understand your question. As you know we have LoadLayout to load a layout designed in the Internal Designer. So you could prepare more than one alternative for a specific Activity and then load the desidered one based on code, settings, whatever.
By "external" do you mean available on a server of yours? In that case, yes, you could download it and make it active by LoadLayout. A key point will be that all the alternative layouts should sport objects named in the same way and your Activity's code should know about them.
Download from server(external) and load it in app
 
Upvote 0

udg

Expert
Licensed User
Longtime User
I searched the forum and found a similar question dated 2012. If that still applies, unfortunately we can't download a bal file from the Internet.

If you need just "cosmetic" changes to a base layout, you could code a module able to download a "scheme" and to apply those parameters to the base layout distributed with your app in the Files directory.

Thinking aloud here..you pass each view of your layout to a "function" named Theming which will check against the downloaded scheme if there are parameters to apply to that view (identified by a string in its tag?) and, if any, it applies them (color, textcolor, font..).

Another possibility is what @DonManfred already posted: set your layout in code.
 
Last edited:
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
I need download it from server and load it in my app.
Can i?
In my understanding (never tried); no

BUT you can for sure create the complete layout by Code based on the information you downloaded from your server. You need to build a good structure to define the needed informations which you use to build the layout by code...
 
Upvote 0

devmobile

Active Member
Licensed User
In my understanding (never tried); no

BUT you can for sure create the complete layout by Code based on the information you downloaded from your server. You need to build a good structure to define the needed informations which you use to build the layout by code...
It is difficult
Can i use layout xml instead of b4a layout?(download from server)
 
Upvote 0

Haris Hafeez

Active Member
Licensed User
Longtime User
A while ago I had a similar requirement. I wanted my layout to be defined at runtime based on some design related information. As others have noted, it is not possible for you to define BAL or Android XML layouts and push them from your server to the client. But there's nothing stopping you from defining your own XML layout format and passing that to the server.
In my case, I used a XML layout description containing tables, rows and columns which I then pushed to my app and the app parsed this XML to create the appropriate layout. My use case was quite complex because I needed validation on the dynamically created controls as well as event listeners on the server for app events but it is certainly not too difficult.
 
Upvote 0

devmobile

Active Member
Licensed User
A while ago I had a similar requirement. I wanted my layout to be defined at runtime based on some design related information. As others have noted, it is not possible for you to define BAL or Android XML layouts and push them from your server to the client. But there's nothing stopping you from defining your own XML layout format and passing that to the server.
In my case, I used a XML layout description containing tables, rows and columns which I then pushed to my app and the app parsed this XML to create the appropriate layout. My use case was quite complex because I needed validation on the dynamically created controls as well as event listeners on the server for app events but it is certainly not too difficult.
What?:eek:
 
Upvote 0

Haris Hafeez

Active Member
Licensed User
Longtime User
As I said, it's not too difficult. You just need to create a 'data model' for your layout, create an instance of it and store in an appropriate format (xml or json for example) on the server and then read it in your code and create the appropriate views. If you state your actual app requirements, I (or in fact many others) may be able to help you think through your options.
 
Upvote 0
Top