Refer to Erel's advice in https://www.b4x.com/android/forum/t...-same-code-phone-or-tablet.73752/#post-468927 ,How do I solved my problem?
My Code Module (SupportedOrientationsScreen) is belows
My code is belows
My Code Module (SupportedOrientationsScreen) is belows
B4X:
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Public Orientation As String
End Sub
Sub SelectOrientation As String
If GetDeviceLayoutValues.Width > GetDeviceLayoutValues.Height Then
Orientation = "Landscape"
Else
Orientation = "Portrait"
End If
Return Orientation
End Sub
B4X:
Sub Activity_Create(firstTime As Boolean)
'put this code in a code module and call it from Activity_Resume of each activity.
'for SupportedOrientations possible values: unspecified, landscape or portrait
Activity.LoadLayout("1")
:::
End Sub
Sub Activity_Resume
IIf(SupportedOrientationsScreen.SelectOrientation="Portrait",Activity.LoadLayout("1"),Activity.LoadLayout("2"))
:::
End Sub