Hallo
Ich möchte ein Menü aus dem Sample "QuickActionExample" NICHT über einen Button sondern über einen Menüpunkt auslösen. Leider erhalte ich immer nur einen Fehler. Wie komme ich an "Sender"???
Was mache ich falsch ?
Martin
Ich möchte ein Menü aus dem Sample "QuickActionExample" NICHT über einen Button sondern über einen Menüpunkt auslösen. Leider erhalte ich immer nur einen Fehler. Wie komme ich an "Sender"???
B4X:
'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 ac1 As AHQuickAction
Dim ac2 As AHQuickAction3D
Dim men As AHPopupMenu
Dim menWagner As AHPopupMenu
Dim Button1 As Button
Dim Button2 As Button
Dim Button3 As Button
Dim ListView1 As ListView
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("l1")
Activity.AddMenuItem("Menü","aufruf")
End Sub
'Sub Activity_Create(FirstTime As Boolean)
' Activity.LoadLayout("l1")
'
' ac1.Initialize("AC")
' ac2.Initialize("AC", ac2.VERTICAL)
' men.Initialize("AC")
'
' For i = 1 To 7
' Dim ai As AHActionItem
' Dim bd As BitmapDrawable
' Dim Filename, Text As String
'
' Select i
' Case 1
' Filename = "menu_up_arrow.png"
' Text = "Prev"
' Case 2
' Filename = "menu_down_arrow.png"
' Text = "Next"
' Case 3
' Filename = "menu_info.png"
' Text = "Info"
' Case 4
' Filename = "menu_eraser.png"
' Text = "Delete"
' Case 5
' Filename = "menu_search.png"
' Text = "Search"
' Case 6
' Filename = "menu_cancel.png"
' Text = "Cancel"
' Case 7
' Filename = "menu_ok.png"
' Text = "Ok"
' End Select
'
' 'Initialize a bitmap drawable and the action item
' bd.Initialize(LoadBitmap(File.DirAssets, Filename))
' ai.Initialize(i, Text, bd)
' ai.Selected = True
'
' 'Make the Prev and Next items sticky so they will not close the popup
' If i = 1 OR i = 2 Then ai.Sticky = True
'
' 'Add the item to both Quickactions popups
' ac1.addActionItem(ai)
' ac2.addActionItem(ai)
' men.AddActionItem(ai)
' Next
'
' For i = 1 To 20
' ListView1.AddSingleLine("Test " & i)
' Next
'
' ' Make a nice opening animation (True is default)
' ac1.AnimateTrack = True
'
' Activity.AddMenuItem("Menü","aufruf")
'
'
'End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
'Event sub when item is selected
Sub AC_Click (Position As Int, ActionItemID As Int)
Dim Action As AHActionItem
Action = ac1.getActionItem(Position)
ToastMessageShow(Action.Title & " pressed", False)
End Sub
'Event Sub when popup window is just dismissed
Sub AC_Dismiss
ToastMessageShow("Dismissed", False)
End Sub
'Open the popups on button click
'Sub Button1_Click
' ac1.show(Sender)
'End Sub
'
'Sub Button2_Click
' ac2.show(Sender)
'End Sub
Sub Aufruf_click
menWagner.Initialize("AC")
For i = 1 To 7
Dim ai As AHActionItem
Dim bd As BitmapDrawable
Dim Filename, Text As String
Select i
Case 1
Filename = "menu_up_arrow.png"
Text = "Prev"
Case 2
Filename = "menu_down_arrow.png"
Text = "Next"
Case 3
Filename = "menu_info.png"
Text = "Info"
Case 4
Filename = "menu_eraser.png"
Text = "Delete"
Case 5
Filename = "menu_search.png"
Text = "Search"
Case 6
Filename = "menu_cancel.png"
Text = "Cancel"
Case 7
Filename = "menu_ok.png"
Text = "Ok"
End Select
'Initialize a bitmap drawable and the action item
bd.Initialize(LoadBitmap(File.DirAssets, Filename))
ai.Initialize(i, Text, bd)
ai.Selected = True
'Make the Prev and Next items sticky so they will not close the popup
If i = 1 OR i = 2 Then ai.Sticky = True
'Add the item to both Quickactions popups
menWagner.AddActionItem(ai)
Next
menWagner.Show(Sender)
End Sub
'Sub Button3_Click
' men.Show(Sender)
'End Sub
Sub ListView1_ItemClick (Position As Int, Value As Object)
ac1.Show(GetViewAtPos(Sender, Position))
End Sub
Sub GetViewAtPos(LV As ListView, Position As Int) As View
Dim r As Reflector
Dim v As View
r.Target = LV
Dim first As Int
first = r.RunMethod("getFirstVisiblePosition")
v = r.RunMethod2("getChildAt", Position - first, "java.lang.int")
Return v
End Sub
Martin