' in Class_Globals
Public itemdialog As B4XDialog
' in B4XPage_Created
itemdialog.Initialize(Root)
itemdialog.PutAtTop = True
itemdialog.BackgroundColor = Colors.LightGray
itemdialog.BodyTextColor = Colors.Blue
Sub btn1_Click
If cbx1.Size < 1 Then
Return
End If
If cbx2.Size < 1 Then
Return
End If
edt1.Initialize("")
Dim pnl1 As Panel = setup_dialog("item_dialog","Add item for " & cbx1.SelectedItem & " - " & cbx2.SelectedItem)
Wait For (itemdialog.ShowCustom(pnl1, "OK", "", "CANCEL")) Complete (Result As Int)
If Result = xui.dialogResponse_Positive Then
If edt1.Text <> "" Then
clv1.AddTextItem(edt1.text,edt1.text)
If clv1.Size > 0 Then
save_list(cbx1.Selecteditem,cbx2.Selecteditem)
End If
End If
End If
End Sub
Sub clv1_ItemClick (Index As Int, Value As Object)
Dim pnl1 As Panel = setup_dialog("item_dialog","Edit/Delete category")
Dim rs1 As ResumableSub = itemdialog.ShowCustom(pnl1, "SAVE", "DELETE", "CANCEL")
edt1.Text = clv1.GetValue(Index)
Wait For (rs1) Complete (Result As Int)
If Result = xui.dialogResponse_Positive Then
If edt1.Text <> "" Then
clv1.RemoveAt(Index)
clv1.InsertAtTextItem(Index,edt1.text,edt1.text)
End If
else if Result = xui.dialogResponse_Negative Then
clv1.RemoveAt(Index)
End If
If clv1.Size > 0 Then
save_list(SelectedItem1,SelectedItem2)
End If
End Sub
Private Sub B4XPage_Appear
clv1.Clear
SelectedIndex1 = 0
SelectedIndex2 = 0
FillComboBox1
End Sub
Private Sub B4XPage_Disappear
If cbx1.Size > 0 Then
If cbx2.Size > 0 Then
save_list(cbx1.Selecteditem,cbx2.Selecteditem)
End If
End If
End Sub