Android Question Starting in B4A with simple browser, stuck on an error

lhatch

Member
Licensed User
I have tried Process Globals and preloading TPage and no luck. Can someone help me out and I will do look for a better tutorial.

browser:
#Region  Project Attributes
    #ApplicationLabel:Browser
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

#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.
    Private xui As XUI
    'Dim TPage As EditText
    'Dim TPage As String
End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    Private Back As Button
    Private Forward As Button
    Private Go As Button
    Private WebView1 As WebView
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("browser")
    TPage = "\"
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Private Sub BGo_Click
    WebView1.LoadUrl(TPage.text)
End Sub

Private Sub BForward_Click
    WebView1.Forward
End Sub

Private Sub BBack_Click
    WebView1.Back
End Sub
1673701859044.png

1673701700470.png
 

lhatch

Member
Licensed User
Thanks Don, I am having a fit over layout.bal, but it now compiles. I did not have the B4Xmainpage, but has another viewer option. I used that. Just noticed there is an update, will pull it and try again. Here is the latest screenshot and code
browser:
#Region  Project Attributes
    #ApplicationLabel:Browser
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

#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.
    Private xui As XUI
End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    Private Back As Button
    Private Forward As Button
    Private Go As Button
    Private WebView1 As WebView
    Private TPage As B4XView
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("browser")
    TPage = "http:\\google.com"
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Private Sub BGo_Click
    WebView1.LoadUrl(TPage.text)
End Sub

Private Sub BForward_Click
    WebView1.Forward
End Sub

Private Sub BBack_Click
    WebView1.Back
End Sub


Private Sub TPage_EnterPressed
   
End Sub

1673706396286.png
 
Last edited:
Upvote 0

OliverA

Expert
Licensed User
Longtime User
Double check line 32. That's where your error is.
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
TPage = "http:\\google.com" should be:TPage.Text = "http:\\google.com"
A word of advice: When you post code that involves a layout with few views, it is always better to include and attach the .bal file, so members do not have to reproduce it to help you. Also, when you post error messages , do not use an image. Use text. Show the error as text
 
Upvote 0

lhatch

Member
Licensed User
TPage = "http:\\google.com" should be:TPage.Text = "http:\\google.com"
A word of advice: When you post code that involves a layout with few views, it is always better to include and attach the .bal file, so members do not have to reproduce it to help you. Also, when you post error messages , do not use an image. Use text. Show the error as text
Also the :// not :\\ got me. I did get everything working. Thanks so much for all the help and recommendations (to ALL here).

I can see a ZIP icon on the upper mid/left in the code/activity windows. Can I hit that and get the .b4a and .bal and others files to unload in the event of future program issues? It that the right way on more complex problems?

Thanks again, have a simple program to write, but started learning from pages and from an example on the internet (imagine, it did not work 100%). I wrote a program years ago in B4A, just been some time and I see it has became much more powerful (and more to learn). Thanks Erel/Anywhere Software.
 
Upvote 0
Top