The attached project wraps this Github project. Posting the following:
1. B4A project demonstrating the code. I strongly suggest that you spend some time on THIS WEBSITE to get an understanding of how to code the formulas (it is a bit tricky...)
2. A Dropbox link to the library files that you will need - copy them to your additional library folder. CLICK HERE TO DOWLOAD THE LIBRARY FILES
3. A Dropbox link to the Files folder of the B4A project. Replace the entire Files folder of the B4A project with this download. CLICK HERE TO DOWNLOAD THE FILES FOLDER OF THE B4A PROJECT
4. The src folder of the Java code. You will need to create a libs folder of the same folder level as the src folder and then copy chunk-templates-3.0.1.jar, android-support-v7-appcompat.jar, and android-support-v4.jar into this libs folder in order to compile it with SLC or Eclipse. These 3 jar files are in the file that you can download from (2) above. CLICK HERE TO DOWNLOAD THE ZIPPED src FOLDER
I am running this on a Samsung S4 Mini with Android 4.4.2 (it is not working on my tablet with Android 4.0.4).
Sample Code:
Thanks Markus (@corwin42), Manfred (@DonManfred) and JP (@freedom2000). Sorry to have bothered you all today but this was by far the most challenging wrapper that I have done and I was running out of ideas.
Please note - I am no expert on creating the B4A code to generate the visual display of the formulas for. For that please see point 1 above.
1. B4A project demonstrating the code. I strongly suggest that you spend some time on THIS WEBSITE to get an understanding of how to code the formulas (it is a bit tricky...)
2. A Dropbox link to the library files that you will need - copy them to your additional library folder. CLICK HERE TO DOWLOAD THE LIBRARY FILES
3. A Dropbox link to the Files folder of the B4A project. Replace the entire Files folder of the B4A project with this download. CLICK HERE TO DOWNLOAD THE FILES FOLDER OF THE B4A PROJECT
4. The src folder of the Java code. You will need to create a libs folder of the same folder level as the src folder and then copy chunk-templates-3.0.1.jar, android-support-v7-appcompat.jar, and android-support-v4.jar into this libs folder in order to compile it with SLC or Eclipse. These 3 jar files are in the file that you can download from (2) above. CLICK HERE TO DOWNLOAD THE ZIPPED src FOLDER
I am running this on a Samsung S4 Mini with Android 4.4.2 (it is not working on my tablet with Android 4.0.4).
Sample Code:
B4X:
#Region Project Attributes
#ApplicationLabel: b4aMathView
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: landscape
#CanInstallToExternalStorage: False
#AdditionalJar: chunk-templates-3.0.1.jar
#End Region
#AdditionalRes: ..\resource
#AdditionalRes: c:\ANDRIOD_SDK_TOOLS\extras\android\support\v7\appcompat\res, android.support.v7.appcompat
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Private mv1 As MathView
Private mv2 As MathView
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("main")
End Sub
Sub Activity_Resume
Dim formula1 As String = "<math xmlns=""http://www.w3.org/1998/Math/MathML"">" & Chr(10) & Chr(13) & _
" <mrow>" & Chr(10) & Chr(13) & _
" <mi>f</mi>" & Chr(10) & Chr(13) & _
" <mrow>" & Chr(10) & Chr(13) & _
" <mo>(</mo>" & Chr(10) & Chr(13) & _
" <mi>a</mi>" & Chr(10) & Chr(13) & _
" <mo>)</mo>" & Chr(10) & Chr(13) & _
" </mrow>" & Chr(10) & Chr(13) & _
" </mrow>" & Chr(10) & Chr(13) & _
" <mo>=</mo>" & Chr(10) & Chr(13) & _
" <mrow>" & Chr(10) & Chr(13) & _
" <mfrac>" & Chr(10) & Chr(13) & _
" <mn>1</mn>" & Chr(10) & Chr(13) & _
" <mrow>" & Chr(10) & Chr(13) & _
" <mn>2</mn>" & Chr(10) & Chr(13) & _
" <mi>π</mi>" & Chr(10) & Chr(13) & _
" <mi>i</mi>" & Chr(10) & Chr(13) & _
" </mrow>" & Chr(10) & Chr(13) & _
" </mfrac>" & Chr(10) & Chr(13) & _
" <msub>" & Chr(10) & Chr(13) & _
" <mo>∮</mo>" & Chr(10) & Chr(13) & _
" <mrow>" & Chr(10) & Chr(13) & _
" <mi>γ</mi>" & Chr(10) & Chr(13) & _
" </mrow>" & Chr(10) & Chr(13) & _
" </msub>" & Chr(10) & Chr(13) & _
" <mfrac>" & Chr(10) & Chr(13) & _
" <mrow>" & Chr(10) & Chr(13) & _
" <mi>f</mi>" & Chr(10) & Chr(13) & _
" <mo>(</mo>" & Chr(10) & Chr(13) & _
" <mi>z</mi>" & Chr(10) & Chr(13) & _
" <mo>)</mo>" & Chr(10) & Chr(13) & _
" </mrow>" & Chr(10) & Chr(13) & _
" <mrow>" & Chr(10) & Chr(13) & _
" <mi>z</mi>" & Chr(10) & Chr(13) & _
" <mo>−</mo>" & Chr(10) & Chr(13) & _
" <mi>a</mi>" & Chr(10) & Chr(13) & _
" </mrow>" & Chr(10) & Chr(13) & _
" </mfrac>" & Chr(10) & Chr(13) & _
" <mi>d</mi>" & Chr(10) & Chr(13) & _
" <mi>z</mi>" & Chr(10) & Chr(13) & _
" </mrow>" & Chr(10) & Chr(13) & _
"</math>"
mv1.MathText = formula1
Dim formula2 As String = "<math xmlns=""http://www.w3.org/1998/Math/MathML"">" & Chr(10) & Chr(13) & _
" <munderover>" & Chr(10) & Chr(13) & _
" <mo>∑<!-- ∑ --></mo>" & Chr(10) & Chr(13) & _
" <mrow class=""MJX-TeXAtom-ORD"">" & Chr(10) & Chr(13) & _
" <mi>i</mi>" & Chr(10) & Chr(13) & _
" <mo>=</mo>" & Chr(10) & Chr(13) & _
" <mn>0</mn>" & Chr(10) & Chr(13) & _
" </mrow>" & Chr(10) & Chr(13) & _
" <mi>n</mi>" & Chr(10) & Chr(13) & _
" </munderover>" & Chr(10) & Chr(13) & _
" <msup>" & Chr(10) & Chr(13) & _
" <mi>i</mi>" & Chr(10) & Chr(13) & _
" <mn>2</mn>" & Chr(10) & Chr(13) & _
" </msup>" & Chr(10) & Chr(13) & _
" <mo>=</mo>" & Chr(10) & Chr(13) & _
" <mfrac>" & Chr(10) & Chr(13) & _
" <mrow>" & Chr(10) & Chr(13) & _
" <mo stretchy=""false"">(</mo>" & Chr(10) & Chr(13) & _
" <msup>" & Chr(10) & Chr(13) & _
" <mi>n</mi>" & Chr(10) & Chr(13) & _
" <mn>2</mn>" & Chr(10) & Chr(13) & _
" </msup>" & Chr(10) & Chr(13) & _
" <mo>+</mo>" & Chr(10) & Chr(13) & _
" <mi>n</mi>" & Chr(10) & Chr(13) & _
" <mo stretchy=""false"">)</mo>" & Chr(10) & Chr(13) & _
" <mo stretchy=""false"">(</mo>" & Chr(10) & Chr(13) & _
" <mn>2</mn>" & Chr(10) & Chr(13) & _
" <mi>n</mi>" & Chr(10) & Chr(13) & _
" <mo>+</mo>" & Chr(10) & Chr(13) & _
" <mn>1</mn>" & Chr(10) & Chr(13) & _
" <mo stretchy=""false"">)</mo>" & Chr(10) & Chr(13) & _
" </mrow>" & Chr(10) & Chr(13) & _
" <mn>6</mn>" & Chr(10) & Chr(13) & _
" </mfrac>" & Chr(10) & Chr(13) & _
"</math>"
mv2.MathText = formula2
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Thanks Markus (@corwin42), Manfred (@DonManfred) and JP (@freedom2000). Sorry to have bothered you all today but this was by far the most challenging wrapper that I have done and I was running out of ideas.
Please note - I am no expert on creating the B4A code to generate the visual display of the formulas for. For that please see point 1 above.
Attachments
Last edited: