asales Expert Licensed User Longtime User Feb 26, 2020 #1 I use this code to - with a long click - remove the click panel: B4X: Sub pnl_LongClick Dim result As Int result = Msgbox2("Confirm?", "Remove panel", "Yes", "", "No", Null) If result <> DialogResponse.Positive Then Return Dim pn As Panel = Sender pn.RemoveView End Sub but If I changed to Msgbox2Async: B4X: Sub pnl_LongClick Msgbox2Async("Confirm?", "Remove panel", "Yes", "", "No", Null, False) Wait For Msgbox_Result (Result As Int) If Result <> DialogResponse.POSITIVE Then Return Dim pn As Panel = Sender pn.RemoveView End Sub I get this error: B4X: chat$ResumableSub_pnl_LongClickresume (java line: 330) java.lang.ClassCastException: android.app.AlertDialog cannot be cast to android.view.ViewGroup at b4a.example.chat$ResumableSub_pnl_LongClick.resume(chat.java:330) How I can fix it? Thanks in advance for any tip.
I use this code to - with a long click - remove the click panel: B4X: Sub pnl_LongClick Dim result As Int result = Msgbox2("Confirm?", "Remove panel", "Yes", "", "No", Null) If result <> DialogResponse.Positive Then Return Dim pn As Panel = Sender pn.RemoveView End Sub but If I changed to Msgbox2Async: B4X: Sub pnl_LongClick Msgbox2Async("Confirm?", "Remove panel", "Yes", "", "No", Null, False) Wait For Msgbox_Result (Result As Int) If Result <> DialogResponse.POSITIVE Then Return Dim pn As Panel = Sender pn.RemoveView End Sub I get this error: B4X: chat$ResumableSub_pnl_LongClickresume (java line: 330) java.lang.ClassCastException: android.app.AlertDialog cannot be cast to android.view.ViewGroup at b4a.example.chat$ResumableSub_pnl_LongClick.resume(chat.java:330) How I can fix it? Thanks in advance for any tip.
DonManfred Expert Licensed User Longtime User Feb 26, 2020 #2 asales said: How I can fix it? Click to expand... after the dialog shown the SENDER has changed I suggest to get the panel ref before showing the dialog. B4X: Sub pnl_LongClick Dim pn As Panel = Sender Msgbox2Async("Confirm?", "Remove panel", "Yes", "", "No", Null, False) Wait For Msgbox_Result (Result As Int) If Result <> DialogResponse.POSITIVE Then Return pn.RemoveView End Sub Upvote 0
asales said: How I can fix it? Click to expand... after the dialog shown the SENDER has changed I suggest to get the panel ref before showing the dialog. B4X: Sub pnl_LongClick Dim pn As Panel = Sender Msgbox2Async("Confirm?", "Remove panel", "Yes", "", "No", Null, False) Wait For Msgbox_Result (Result As Int) If Result <> DialogResponse.POSITIVE Then Return pn.RemoveView End Sub
DonManfred Expert Licensed User Longtime User Feb 26, 2020 #4 DonManfred said: If Result <> DialogResponse.POSITIVE Then Return Click to expand... This line aborts... after a Positive result (YES to delete) the sub just returns... change it to B4X: If Result <> DialogResponse.NEGATIVE Then Return Upvote 0
DonManfred said: If Result <> DialogResponse.POSITIVE Then Return Click to expand... This line aborts... after a Positive result (YES to delete) the sub just returns... change it to B4X: If Result <> DialogResponse.NEGATIVE Then Return