Android Question What is wrong in my codes? (Open WebView on new Activity)

gacar

Active Member
I want open webview object on new Activity page. Below my codes

My B4XMainPage

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
#End Region

Sub Class_Globals
    Private Root As B4XView
    Private xui As XUI 
    Private WebView1 As WebView
End Sub

Public Sub Initialize
'    B4XPages.GetManager.LogEvents = True
End Sub
 
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("MainPage")
    WebView1.LoadUrl("https://google.com") '<----------- Here working well
End Sub
 
Private Sub Button1_Click 
    StartActivity(Activity2)
End Sub

My FrmActivity2Page (FrmActivity2.bal)

B4X:
Sub Class_Globals
    Private Root As B4XView 'ignore
    Private xui As XUI 'ignore
    Private WebView1 As WebView   
End Sub

'You can add more parameters here.
Public Sub Initialize As Object
    Return Me
End Sub
 
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("FrmActivity2")
    WebView1.LoadUrl("https://google.com") '<----------- Here cannot working
End Sub

Private Sub Button1_Click  
    StartActivity(Activity2)
End Sub

My second activity page
B4X:
#Region  Activity Attributes 
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
   
End Sub

Sub Globals

End Sub

Sub Activity_Create(FirstTime As Boolean)  
    Activity.LoadLayout("FrmActivity2") 
End Sub

Sub Activity_Resume 
    
End Sub

Sub Activity_Pause (UserClosed As Boolean) 
    
End Sub
 

Attachments

  • WebViewAndActivity.zip
    16.8 KB · Views: 98

gacar

Active Member
Upvote 0

gacar

Active Member
B4XActivity2Page will never be created. You should move the code to Activity2.
Which code move to Activity2?

if i put this code to Activit2
B4X:
Sub Activity_Create(FirstTime As Boolean)   
    Dim pm As B4XPagesManager
    pm.initialize(Activity)
    Activity.LoadLayout("FrmActivity2") 
End Sub

then opening B4XMainPage.
 
Upvote 0
Top