German B4X

Sinan Tuzcu

Well-Known Member
Licensed User
Longtime User
Hallo,

ich habe eine Activity dessen inhalt so ausschaut:
B4X:
#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: false   
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Public ActionBarHomeClicked As Boolean
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.

    
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("Layout1")
    Dim pm As B4XPagesManager
    pm.Initialize(Activity)
End Sub

#Region Delegates

Sub Activity_ActionBarHomeClick
    ActionBarHomeClicked = True
    B4XPages.Delegate.Activity_ActionBarHomeClick
    ActionBarHomeClicked = False
End Sub

Sub Activity_KeyPress (KeyCode As Int) As Boolean
    Return B4XPages.Delegate.Activity_KeyPress(KeyCode)
End Sub

Sub Activity_Resume
    B4XPages.Delegate.Activity_Resume
End Sub

Sub Activity_Pause (UserClosed As Boolean)
    B4XPages.Delegate.Activity_Pause
End Sub

Sub Activity_PermissionResult (Permission As String, Result As Boolean)
    B4XPages.Delegate.Activity_PermissionResult(Permission, Result)
End Sub

Sub Create_Menu (Menu As Object)
    B4XPages.Delegate.Create_Menu(Menu)
End Sub

#if Java
public boolean _onCreateOptionsMenu(android.view.Menu menu) {
     processBA.raiseEvent(null, "create_menu", menu);
     return true;
    
}
#End If
#End Region

dann habe ich noch den B4XMainPage die schaut so aus:
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 pnlPreview As B4XView
    
    
    Private rp As RuntimePermissions
    Private detector As JavaObject
    Private camEx As CameraExClass
    Private LastPreview As Long
    Private IntervalBetweenPreviewsMs As Int = 100

    Private toast As BCToast
    Private QRbtnStartStop As B4XView
End Sub

'You can add more parameters here.
Public Sub Initialize
    
End Sub

'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("CameraPage")
    toast.Initialize(Root)
    StopCamera
    CreateDetector (Array("CODE_128", "CODE_93", "QR_CODE"))
End Sub

Sub QRbtnStartStop_Click

    
    If Capturing = False Then
        StartCamera
    Else
        StopCamera
    End If
End Sub

wenn ich das Activity per StartActivity("CameraPage") aufrufe,
dann kann ich auf QRbtnStartStop_Click klicken und es funktioniert.

Aber wenn ich die Activity nicht mit StartActivity("CameraPage") aufrufe, sondern
in ein Panel lade
B4X:
cont.LoadLayout("CameraPage")
dann haben die Buttons keinen reaktion.

kann mir einer sagen, was ich hier machen muss, wenn ich ein activitiy in einen Panel lade und nicht per StartActivitiy aufrufe?

Danke im Voraus
Sinan
 
Top