W warayTek Member Licensed User Jan 23, 2024 #1 Hello there, I have 4 radio buttons in a panel(using Xcustomlistview), as shown below How do I get all the selected radio values after the submit button?
Hello there, I have 4 radio buttons in a panel(using Xcustomlistview), as shown below How do I get all the selected radio values after the submit button?
Erel B4X founder Staff member Licensed User Longtime User Jan 23, 2024 #2 Check the example here: https://www.b4x.com/android/forum/t...-cross-platform-customlistview.84501/#content Upvote 0
Check the example here: https://www.b4x.com/android/forum/t...-cross-platform-customlistview.84501/#content
W warayTek Member Licensed User Jan 23, 2024 #3 I am getting this error, when click submit button. Code: Copy *** Service (starter) Create *** ** Service (starter) Start ** ** Activity (main) Create (first time) ** Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events. ** Activity (main) Resume ** Submit 1 page2$ResumableSub_getAnswersresume (java line: 149) java.lang.RuntimeException: Object should first be initialized (B4XView). at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:67) at b4a.example3.customlistview._getitemfromview(customlistview.java:406) at exam24.sys.page2$ResumableSub_getAnswers.resume(page2.java:149) at exam24.sys.page2._getanswers(page2.java:122) at exam24.sys.page2._b4xpage_menuclick(page2.java:75) at java.lang.reflect.Method.invoke(Native Method) at anywheresoftware.b4a.BA.raiseEvent2(BA.java:221) at anywheresoftware.b4a.BA$1.run(BA.java:360) at android.os.Handler.handleCallback(Handler.java:883) at android.os.Handler.dispatchMessage(Handler.java:100) at android.os.Looper.loop(Looper.java:264) at android.app.ActivityThread.main(ActivityThread.java:7581) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:980) I attached the code that I am working on. Attachments examiner_sys.zip examiner_sys.zip 14.1 KB · Views: 349 Upvote 0
I am getting this error, when click submit button. Code: Copy *** Service (starter) Create *** ** Service (starter) Start ** ** Activity (main) Create (first time) ** Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events. ** Activity (main) Resume ** Submit 1 page2$ResumableSub_getAnswersresume (java line: 149) java.lang.RuntimeException: Object should first be initialized (B4XView). at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:67) at b4a.example3.customlistview._getitemfromview(customlistview.java:406) at exam24.sys.page2$ResumableSub_getAnswers.resume(page2.java:149) at exam24.sys.page2._getanswers(page2.java:122) at exam24.sys.page2._b4xpage_menuclick(page2.java:75) at java.lang.reflect.Method.invoke(Native Method) at anywheresoftware.b4a.BA.raiseEvent2(BA.java:221) at anywheresoftware.b4a.BA$1.run(BA.java:360) at android.os.Handler.handleCallback(Handler.java:883) at android.os.Handler.dispatchMessage(Handler.java:100) at android.os.Looper.loop(Looper.java:264) at android.app.ActivityThread.main(ActivityThread.java:7581) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:980) I attached the code that I am working on.
LucaMs Expert Licensed User Longtime User Jan 24, 2024 #4 B4X: Copy Private Sub getAnswers Dim checkedItems As List checkedItems.Initialize 'find all checked items. Dim ItemPanel As B4XView For i = 0 To clv1.Size - 1 ItemPanel = clv1.GetPanel(i) For Each xView As B4XView In ItemPanel.GetAllViewsRecursive If xView Is RadioButton Then If xView.Checked Then checkedItems.Add(i) Exit End If End If Next Next 'Remember that the indices of the CustomListView items start from zero. Log("Checked items: " & checkedItems) End Sub The Sender variable contains (always, not only with CustomListViews) a reference to the object that triggered an event; in your case it is the menu item in B4XPage_MenuClick and you don't need it (and Sender "does not exist" in your Sub getAnswers). ["Better" B4XPage_Created of B4XMainPage] B4X: Copy Private Sub B4XPage_Created (Root1 As B4XView) Root = Root1 Root.LoadLayout("MainPage") B4XPages.SetTitle(Me, "") examPage.Initialize B4XPages.AddPage("ExamPage",examPage) End Sub [Update your B4A to the last current version, 12.80] Last edited: Jan 24, 2024 Upvote 0
B4X: Copy Private Sub getAnswers Dim checkedItems As List checkedItems.Initialize 'find all checked items. Dim ItemPanel As B4XView For i = 0 To clv1.Size - 1 ItemPanel = clv1.GetPanel(i) For Each xView As B4XView In ItemPanel.GetAllViewsRecursive If xView Is RadioButton Then If xView.Checked Then checkedItems.Add(i) Exit End If End If Next Next 'Remember that the indices of the CustomListView items start from zero. Log("Checked items: " & checkedItems) End Sub The Sender variable contains (always, not only with CustomListViews) a reference to the object that triggered an event; in your case it is the menu item in B4XPage_MenuClick and you don't need it (and Sender "does not exist" in your Sub getAnswers). ["Better" B4XPage_Created of B4XMainPage] B4X: Copy Private Sub B4XPage_Created (Root1 As B4XView) Root = Root1 Root.LoadLayout("MainPage") B4XPages.SetTitle(Me, "") examPage.Initialize B4XPages.AddPage("ExamPage",examPage) End Sub [Update your B4A to the last current version, 12.80]