Landscape/Portrait Issue

bishmedia

Member
Licensed User
Longtime User
I have a simple App that uses 'webview' and 4 buttons.
The following is the onload code.

Code: Copy
Sub Activity_Create(FirstTime As Boolean)
   WebView1.Initialize("brass_band_Click")
   Activity.LoadLayout("brass_band")
   WebView1.LoadURL("http://www.rushdenwindmillband.com/Apps/master.php")
End Sub

When i press a button it shows a website like the following..

Code: Copy
Sub btnDown1_Click
    WebView1.LoadURL("http://www.4barsrest.com")
    Dim WebViewSettings1 As WebViewSettings
    WebViewSettings1.setDefaultZoom(WebView1, "FAR")
    WebViewSettings1.setLoadWithOverviewMode(WebView1, True)    
    WebViewSettings1.setUseWideViewPort(WebView1, True)
End Sub

Pressing the buttons to reveal a website works fine but when i rotate the phone/tablet to Landscape it seems to retrigger the onload event and load the first webiste??

Am i missing something???
 
This prevents your code running after an orientation change ..

Code: Copy
Sub Activity_Create(FirstTime As Boolean)
  If FirstTime Then
    WebView1.Initialize("brass_band_Click")
    Activity.LoadLayout("brass_band")
    WebView1.LoadURL("http://www.rushdenwindmillband.com/Apps/master.php")
  end if
End Sub

you might want to have a read here ..
android process activities life cycles

Especially the section ..
Sub Activity_Create (FirstTime As Boolean)

This sub is called when the activity is created.
The activity is created when the user first launches the application, the device configuration has changed (user rotated the device) and ...

Cheers mj
 
Upvote 0
Ah thats great, i did want it to stay as landscape and found changing
#SupportedOrientations: to landscape did the job :-)
 
Upvote 0
Back
Top