Android Question [solved]b4xtemplate in B4J is not alike in B4A

Theera

Well-Known Member
Licensed User
Longtime User
Hi all,
I have created my b4xtemplate by mixing Klaus's and Erel's ,but when I add the command #If B4A in B4A Ide,why not changed in B4J (there is not have #If B4A command in B4J) after I have saved.

B4X:
'Klaus 's template code
....
....
'Erel's template addition only B4A 1.01
#if B4A  '<==Add the command
#Region Delegates

Sub Activity_ActionBarHomeClick
    B4XPages.Delegate.Activity_ActionBarHomeClick
End Sub

Sub Activity_KeyPress (KeyCode As Int) As Boolean
    Return B4XPages.Delegate.Activity_KeyPress(KeyCode)
End Sub

Sub Activity_Resume
    B4XPages.Delegate.Activity_Resume
End Sub

Sub Activity_Pause (UserClosed As Boolean)
    B4XPages.Delegate.Activity_Pause
End Sub

Sub Activity_PermissionResult (Permission As String, Result As Boolean)
    B4XPages.Delegate.Activity_PermissionResult(Permission, Result)
End Sub

Sub Create_Menu (Menu As Object)
    B4XPages.Delegate.Create_Menu(Menu)
End Sub

#if Java
public boolean _onCreateOptionsMenu(android.view.Menu menu) {
     processBA.raiseEvent(null, "create_menu", menu);
     return true;
  
}
#End If
#End Region

#End If
 

klaus

Expert
Licensed User
Longtime User
What exactly do you want or you are trying to do.

The difference between Erel's template and mine is only on top of the B4XMainPage module, the Main module is exactly the same.
Erel's template:
B4X:
'Ctrl + click to export as zip: ide://run?File=%B4X%\Zipper.jar&Args=Project.zip

My template:
B4X:
'Ctrl + click to export as zip: ide://run?File=%B4X%\Zipper.jar&Args=\%PROJECT_NAME%.zip

'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
In the first line, Args=Project.zip has been replaced by Args=\%PROJECT_NAME%.zip.
With this modification the name of the project zip file is not always Project.zip but ProjectName.zip where ProjectName is the name of the current project.
No need to always change the name of the zip file.
And I added three more lines which allow to run directly the IDE for another platform with the same project from within the IDE.
 
Upvote 0

Theera

Well-Known Member
Licensed User
Longtime User
Ok, I can get it. Usually,Erel has his template each platform(B4A,B4i,B4J) in the main of each module. When we have additional template ,we must code it in B4xMainPage. So then I thinked move each Erel's template into the B4xMainPage by using #if B4A,#if B4J and #if B4i commands that we can do them. It's my mistake that forgot to remove the code in each the main module ,so then there is error. Now I understand all. Thank you all of you.
 
Upvote 0

Theera

Well-Known Member
Licensed User
Longtime User
I tried to control Erel'template each platform and Klaus's template are in the same only the B4XMainPage.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
I tried to control Erel'template each platform and Klaus's template are in the same only the B4XMainPage.
I still do not understand what you want to achieve.

To create a new template, the best way is to use an existing one, make your changes in the B4XMainPage module and zip it like as a B4XPages project with a new name with the b4xtemplate suffix.
Then copy the zip file to the AdditionlaLibrarie\B4X folder.
gain, all this is explained in the B4X Cross-platform projects booklet.
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
What exactly do you want or you are trying to do.

The difference between Erel's template and mine is only on top of the B4XMainPage module, the Main module is exactly the same.
Erel's template:
B4X:
'Ctrl + click to export as zip: ide://run?File=%B4X%\Zipper.jar&Args=Project.zip

My template:
B4X:
'Ctrl + click to export as zip: ide://run?File=%B4X%\Zipper.jar&Args=\%PROJECT_NAME%.zip

'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
In the first line, Args=Project.zip has been replaced by Args=\%PROJECT_NAME%.zip.
With this modification the name of the project zip file is not always Project.zip but ProjectName.zip where ProjectName is the name of the current project.
No need to always change the name of the zip file.
And I added three more lines which allow to run directly the IDE for another platform with the same project from within the IDE.
Klaus, in which booklet can I find the documentation about those commands?
 
Upvote 0

Theera

Well-Known Member
Licensed User
Longtime User
Your code is the same as the lastest of mine.
Hi Aeric,
I 'm sorry that make you angry. I have edited my code as klaus' advise. And then compare your code. They are now the same code.
I always respect to you. Thank you for your help. Please forgive to me,sir.
 
Last edited:
Upvote 0

Theera

Well-Known Member
Licensed User
Longtime User
I'm sorry my English that I need to write "forgive" me ,but not be "give up".

give up =ยอมแพ้
forgive =ให้อภัย
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Last edited:
Upvote 0

Mahares

Expert
Licensed User
Longtime User
'Ctrl + click to export as zip: ide://run?File=%B4X%\Zipper.jar&Args=\%PROJECT_NAME%.zip '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
Shouldn't Erel include the above 4 lines in his B4XPages template as they are really helpful. If you agree, then I can create a 'Wish' thread. If it is not that important, then I will refrain.
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Shouldn't Erel include the above 4 lines in his B4XPages template as they are really helpful. If you agree, then I can create a 'Wish' thread. If it is not that important, then I will refrain.
Yes, I think you "should" open a "Wish", it will be granted very soon (not right away but only because Erel is not online).

Obviously I will continue to use my template, as it is very beautiful 😄
 
Last edited:
Upvote 0
Top