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
 

Theera

Well-Known Member
Licensed User
Longtime User
Most of the time you should not modify the Main activity.
I have modified only in B4XMainPage,but. Why they are not alike each together.
 
Upvote 0

Theera

Well-Known Member
Licensed User
Longtime User
Please to test my b4xtemplate,and test new projects both in B4A and B4J
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
Of course B4A and B4J are different. One use Activity the other use Form. B4A uses action bar but B4J use menu. You can't expect they appear the same. That's why B4XPages is a solution to make our job simpler.

I don't understand your question without you provide more accurate information.
 
Upvote 0

Sandman

Expert
Licensed User
Longtime User
My best parsing of this thread is that @Theera is expressing confusion of one of these two:

1. Why B4i, B4A and B4J have different Main.

2. He has made a project and afterwards changed the template, and is now confused why the project isn't automatically updated to match the changed template.

Sorry if that's bad interpretation, I did my best to help.
 
Upvote 0

Theera

Well-Known Member
Licensed User
Longtime User
my file I'm sorry my computer is so very lately
 
Upvote 0

Theera

Well-Known Member
Licensed User
Longtime User
Of course B4A and B4J are different. One use Activity the other use Form. B4A uses action bar but B4J use menu. You can't expect they appear the same. That's why B4XPages is a solution to make our job simpler.

I don't understand your question without you provide more accurate information.
I understand that then I use #if B4A condition for detecting in B4XMainPage. But it is not appear in B4J. (Usually,the code in B4XMainPage must be the same code the most of B4A ,B4i,and B4J
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
I understand that then I use #if B4A condition for detecting in B4XMainPage. But it is not appear in B4J.
It appears! but with error.

The code in post #1 is not needed in B4XMainPage class. It is already added in B4A Main module.


To create your own custom template, you should export the project using
B4X:
'Ctrl + click to export as zip: ide://run?File=%B4X%\Zipper.jar&Args=Project.zip
then you get a clean project.
 
Upvote 0

Theera

Well-Known Member
Licensed User
Longtime User
B4X:
Ctrl + click to export as zip: ide://run?File=%B4X%\Zipper.jar&Args=Project.zip

Is there way to replace project.zip with %AppName%.zip
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
I have modified only in B4XMainPage,but. Why they are not alike each together.
No, you have modified the Main module with the #If B4A statement and not the B4XMainPage module.
The Main modules are specific for each platform, and therefore different, and belong to the *.b4a, *.b4j and *.b4i file and these are not shared between the platforms.
These files are located in their specific platform sub folder.
There is no need to modify the Main module and try to write code for more than one platform.
The B4XMainPage module is a common file, B4XMainPage.bas, for all three platforms and is located in the project folder.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Upvote 0

Theera

Well-Known Member
Licensed User
Longtime User
No, you have modified the Main module with the #If B4A statement and not the B4XMainPage module.
The Main modules are specific for each platform, and therefore different, and belong to the *.b4a, *.b4j and *.b4i file and these are not shared between the platforms.
These files are located in their specific platform sub folder.
There is no need to modify the Main module and try to write code for more than one platform.
The B4XMainPage module is a common file, B4XMainPage.bas, for all three platforms and is located in the project folder.

I think we can move Erel' template from Main module to B4XMainPage as well
 
Upvote 0

Theera

Well-Known Member
Licensed User
Longtime User
Sorry, I do not understand what you mean with this.
We can move Erel 's template from Main Module to B4XMainPage the same your template (Klaus' template) is by using #If B4A command. please see my code #1
 
Upvote 0
Top