This is my experience with B4X. In B4X you create a program that runs on multiple platforms (Windows, Android, Ipads, etc.) at once. I am an amateur with some experience myself.
This sample app is a simple guessing game.
Here are my tips: (read the instructions about B4X anyway)
0. Don't be stupid like me and don't forget to change your packagename (thanks the Community) that saves a lot of wasted time...
1. Initially I developed it completely in B4J, so for Windows. But only use the B4X views.
2. I have edited the Layout as much as possible with Anchors and the script, so that everything remains in proportion when resize in Widows.
'All variants script
AutoScaleAll
ButtonAskBeta.Left=50%x-(ButtonAskBeta.Width/2)
TextAreaInfo.Left=100%x-(TextAreaInfo.Width)-20dip
ButtonSolution.Top=100%y-ButtonSolution.Height
3. You add the following lines in B4J: (see also the instructions about B4X)
#Region Shared Files
#CustomBuildAction: folders ready, %WINDIR%\System32\Robocopy.exe,"..\..\Shared Files" "..\Files"
'Ctrl + click to sync files: ide://run?file=%WINDIR%\System32\Robocopy.exe&args=..\..\Shared+Files&args=.. \Files&FilesSync=True
'B4A ide://run?file=%WINDIR%\System32\cmd.exe&Args=/c&Args=start&Args=..\..\B4A\%PROJECT_NAME%.b4a
'B4i ide://run?file=%WINDIR%\System32\cmd.exe&Args=/c&Args=start&Args=..\..\B4i\%PROJECT_NAME%.b4i
'B4J ide://run?file=%WINDIR%\System32\cmd.exe&Args=/c&Args=start&Args=..\..\B4J\%PROJECT_NAME%.b4j
#End Region
'Ctrl + click to export as zip: ide://run?File=%B4X%\Zipper.jar&Args=TheThruth.zip
4. Test the program in Windows until you are completely satisfied.
5. Now place B4A next to your B4J via the line in point 3.
'B4A ide://run?file=%WINDIR%\System32\cmd.exe&Args=/c&Args=start&Args=..\..\B4A\%PROJECT_NAME%.b4a
(Click on it with Ctrl pressed)
6. From B4J in the Designer, copy all views, panels, etc. to the Designer of B4A.
7. Now go to B4A and adjust the screens in Designer and test it in the WYSIWYG. Use Anchors and the scripts and run the script.
8. In B4A I needed something extra (for example to detect the Device).
9. In B4A you put those extra program lines between: #if B4A and #End if. Otherwise your B4J source is no longer correct. (Note that everything is interchanged between B4A and B4J and vice versa.
#if B4A
Dim Phone1 As Phone
#end if
10. Test your APK via Bridge or use the Emulator (actually pretty good that emulator from B4X). And finished!
For the sake of convenience, I chose this simple app:
- Can only be used in portrait in a Phone.
- In a tablet only screenorientation can be used after New and not during the game (otherwise I have to save and retrieve all kinds of variables).
- I've only looked at Windows and Android now.
I'm curious if my method is correct. There will probably be improvements, especially with larger and complicated programs.
Hereby the game. Never thrust the devil...
This sample app is a simple guessing game.
Here are my tips: (read the instructions about B4X anyway)
0. Don't be stupid like me and don't forget to change your packagename (thanks the Community) that saves a lot of wasted time...
1. Initially I developed it completely in B4J, so for Windows. But only use the B4X views.
2. I have edited the Layout as much as possible with Anchors and the script, so that everything remains in proportion when resize in Widows.
'All variants script
AutoScaleAll
ButtonAskBeta.Left=50%x-(ButtonAskBeta.Width/2)
TextAreaInfo.Left=100%x-(TextAreaInfo.Width)-20dip
ButtonSolution.Top=100%y-ButtonSolution.Height
3. You add the following lines in B4J: (see also the instructions about B4X)
#Region Shared Files
#CustomBuildAction: folders ready, %WINDIR%\System32\Robocopy.exe,"..\..\Shared Files" "..\Files"
'Ctrl + click to sync files: ide://run?file=%WINDIR%\System32\Robocopy.exe&args=..\..\Shared+Files&args=.. \Files&FilesSync=True
'B4A ide://run?file=%WINDIR%\System32\cmd.exe&Args=/c&Args=start&Args=..\..\B4A\%PROJECT_NAME%.b4a
'B4i ide://run?file=%WINDIR%\System32\cmd.exe&Args=/c&Args=start&Args=..\..\B4i\%PROJECT_NAME%.b4i
'B4J ide://run?file=%WINDIR%\System32\cmd.exe&Args=/c&Args=start&Args=..\..\B4J\%PROJECT_NAME%.b4j
#End Region
'Ctrl + click to export as zip: ide://run?File=%B4X%\Zipper.jar&Args=TheThruth.zip
4. Test the program in Windows until you are completely satisfied.
5. Now place B4A next to your B4J via the line in point 3.
'B4A ide://run?file=%WINDIR%\System32\cmd.exe&Args=/c&Args=start&Args=..\..\B4A\%PROJECT_NAME%.b4a
(Click on it with Ctrl pressed)
6. From B4J in the Designer, copy all views, panels, etc. to the Designer of B4A.
7. Now go to B4A and adjust the screens in Designer and test it in the WYSIWYG. Use Anchors and the scripts and run the script.
8. In B4A I needed something extra (for example to detect the Device).
9. In B4A you put those extra program lines between: #if B4A and #End if. Otherwise your B4J source is no longer correct. (Note that everything is interchanged between B4A and B4J and vice versa.
#if B4A
Dim Phone1 As Phone
#end if
10. Test your APK via Bridge or use the Emulator (actually pretty good that emulator from B4X). And finished!
For the sake of convenience, I chose this simple app:
- Can only be used in portrait in a Phone.
- In a tablet only screenorientation can be used after New and not during the game (otherwise I have to save and retrieve all kinds of variables).
- I've only looked at Windows and Android now.
I'm curious if my method is correct. There will probably be improvements, especially with larger and complicated programs.
Hereby the game. Never thrust the devil...