I need to create an action sheet where the user select one of many items. Do I use activity form to do this or a custom dialog box? If a dialog box is there a custom library like those in b4a?
You need to:
1) Dim the ActionSheet in Process_Globals Private ashPages As ActionSheet
2) Initialize it in Application_Start. ashEdit.Initialize("ashEdit", "", "Cancel", "Delete", Array As String("Add", "Edit", "Insert"))
Initialize parameters:
Initialize(EventName As String, Title As String, CancelItem As String, DestructiveItem As String, OtherItems As List)
Apple recommends to not use the Title. Apple documentation.
3) Add an event routine.
B4X:
' ActionSheet Edit event routine
Private Sub ashEdit_Click(Item As String)
Select Item
Case "Cancel"
Msgbox("'Cancel' clicked", "Editing")
Case "Add"
Msgbox("'Add' clicked", "Editing")
Case "Edit"
Msgbox("'Edit' clicked", "Editing")
Case "Insert"
Msgbox("'Insert' clicked", "Editing")
Case "Delete"
Msgbox2("msgDelete", "Dou you really want to delete the entry ?", "Editing", Array ("Yes", "No"))
End Select
End Sub
4) Show the ActionSheet somewhere in the code.
Can be any Page.RootPanel. ashEdit.Show(Page1.RootPanel)
Private Sub Application_Start (Nav As NavigationController)
ashColor.Initialize("AshColor","Pick a Color","Cancel","Delete",ArrayAsString("Red","Green","Blue"))
End Sub
Sub cmdSelectAColor_Click
ashColor.Show(Page1.RootPanel)
End Sub
Private Sub ashColor_Click(item As String)
hd.ToastMessageShow(item, True)
End Sub
I see Delete but not cancel. What happened?
the event routine uses (groupname defined in the initialize for routine)
B4X:
ashGroups.Initialize("ashGroups","Pick A Group","Cancel","",oGroupsList)
ashGroups.Show(ScrollViewInput.Panel)
...
B4X:
Private Sub ashGroups_Click(sItem As String)
Dim arrElements() As String
arrElements=Regex.Split("-",sItem)
If arrElements.Length>0 Then
sGlobalGroupId=arrElements(0)
cmdGroup.Text=arrElements(1)
sGlobalGroupIdText=arrElements(1)
LoadTestIdValues
EndIf
end sub