Vereinfacht der QuellcodeSub Process_Globals
End Sub
Sub Globals
Dim btnabout, btnprodukte, btnangebote, btngutscheine, btnback As Button
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("main")
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub btnabout_Click
RemoveViews
Activity.LoadLayout("about")
End Sub
Sub btnprodukte_Click
RemoveViews
Activity.LoadLayout("produkte")
End Sub
Sub RemoveViews
Dim i As Int
For i=Activity.NumberOfViews-1 To 0 Step -1
Activity.RemoveViewAt(i)
Next
End Sub
Sub Activity_KeyPress (KeyCode As Int) As Boolean 'Return True to consume the event
Dim Antw As Int
If KeyCode = KeyCodes.KEYCODE_BACK Then
Antw = Msgbox2("Wollen Sie wirklich das Programm verlassen ?", "ACHTUNG", "Ja", "", "Nein", Null)
If Antw = DialogResponse.POSITIVE Then
Return False
Else
Return True
End If
Else
Return False
End If
End Sub
Sub btnabout_Click
StartActivity(about)
End Sub
Sub btnprodukte_Click
StartActivity(produkte)
End Sub
[...]
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("about")
[...]
End Sub
ach so! Jetzt verstehe ich.Und in der Testversion kann ich ja keine module erstellen, leider
'Activity module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
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.
Dim CurrentView As String
' Main
Dim pnlMain As Panel
Dim lblMainHeader As Label
Dim cmdMainProducts As Button
Dim cmdMainAbout As Button
' Products
Dim pnlProducts As Panel
Dim lblProductsHeader As Label
' About
Dim pnlAbout As Panel
Dim lblAboutHeader As Label
End Sub
Sub Activity_Create(FirstTime As Boolean)
' Main
pnlMain.Initialize("pnlMain")
lblMainHeader.Initialize("lblMainHeader")
lblMainHeader.Text="Main"
cmdMainProducts.Initialize("cmdMainProducts")
cmdMainProducts.Text="Produkte"
cmdMainAbout.Initialize("cmdMainAbout")
cmdMainAbout.Text="About"
Activity.AddView(pnlMain, 0, 0, 100%X, 100%Y)
pnlMain.AddView(lblMainHeader, 10dip, 10dip, 200dip, 40dip)
pnlMain.AddView(cmdMainProducts, 10dip, 60dip, 200dip, 100dip)
pnlMain.AddView(cmdMainAbout, 10dip, 170dip, 200dip, 100dip)
' Produkte
pnlProducts.Initialize("pnlProducts")
lblProductsHeader.Initialize("lblProductsHeader")
lblProductsHeader.Text="Produkte"
Activity.AddView(pnlProducts, 0, 0, 100%X, 100%Y)
pnlProducts.AddView(lblProductsHeader, 10dip, 10dip, 200dip, 40dip)
' About
pnlAbout.Initialize("pnlAbout")
lblAboutHeader.Initialize("lblAboutHeader")
lblAboutHeader.Text="About"
Activity.AddView(pnlAbout, 0, 0, 100%X, 100%Y)
pnlAbout.AddView(lblAboutHeader, 10dip, 10dip, 200dip, 40dip)
SetView("main")
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub cmdMainProducts_Click
SetView("products")
End Sub
Sub cmdMainAbout_Click
SetView("about")
End Sub
Sub Activity_KeyPress (KeyCode As Int) As Boolean 'Return True to consume the event
If KeyCode = KeyCodes.KEYCODE_BACK Then
Select Case CurrentView
Case "main"
Return Msgbox2("Wollen Sie wirklich das Programm verlassen?", "ACHTUNG", "Ja", "", "Nein", Null) = DialogResponse.NEGATIVE
Case "products"
SetView("main")
Return True
Case "about"
SetView("main")
Return True
End Select
Else
Return False
End If
End Sub
Sub SetView(viewname As String)
pnlMain.Visible = False
pnlProducts.Visible = False
pnlAbout.Visible = False
Select Case viewname
Case "main"
pnlMain.Visible = True
Case "products"
pnlProducts.Visible = True
Case "about"
pnlAbout.Visible = True
End Select
CurrentView = viewname
End Sub
Man kann für jedes Panel eine Layoutdatei erstellen und diese, zum Beispiel, mit pnlProdukte.LoadLayout("produkte") lesen.Designer Panels zwar anzeigen kann, diese allerdings nicht wirklich Container-
Funktionalitäten besitzen, musst Du Deine Controls im Code erstellen:
Danke für den Tipp!Man kann für jedes Panel eine Layoutdatei erstellen und diese, zum Beispiel, mit pnlProdukte.LoadLayout("produkte") lesen.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?