msali Member Licensed User Longtime User Mar 31, 2018 #1 Hi, Following what I read at the link: (https://www.b4x.com/android/forum/threads/customfloatingmenubutton-b4a-library-source-code.85485/) I started creating my own library (first attempt) for a bigger project that i am planning for. It is basically a toggle button library as shown in attached image but will grow and get further customized as per my project's need (with time). So far all is working fine. Problem: But the problem is when i rotate the phone. then the application crashes. I have attached an example usage code and the library too. would appreciate your help. many thanks in advance. Attachments ToggleButtonsLib_v1.1.zip ToggleButtonsLib_v1.1.zip 6.4 KB · Views: 485 tgbLR_Fruits.png 70.5 KB · Views: 795 ToggleButtonExample_2.zip ToggleButtonExample_2.zip 9.8 KB · Views: 528 Last edited: Apr 3, 2018
Hi, Following what I read at the link: (https://www.b4x.com/android/forum/threads/customfloatingmenubutton-b4a-library-source-code.85485/) I started creating my own library (first attempt) for a bigger project that i am planning for. It is basically a toggle button library as shown in attached image but will grow and get further customized as per my project's need (with time). So far all is working fine. Problem: But the problem is when i rotate the phone. then the application crashes. I have attached an example usage code and the library too. would appreciate your help. many thanks in advance.
Erel B4X founder Staff member Licensed User Longtime User Apr 3, 2018 #3 It is better to post the solution so this thread can help others... Upvote 0
msali Member Licensed User Longtime User Apr 3, 2018 #4 Erel said: It is better to post the solution so this thread can help others... Click to expand... Solution was as follows: Step 1: Declared a MAP variable Sub Process_Globals Code: Copy Private mapState As Map Step 2: Save the state in Sub Activity_Pause Code: Copy Sub Activity_Pause (UserClosed As Boolean) mapState.Put("LR", tgbLR.GetCurrentButtonName) mapState.Put("Fruits", tgbFrutis.GetCurrentButtonName) End Sub Step 3: In Sub Activity_Create, initialize the mapState if FirstTime was True or Get & Set the State if False Code: Copy If FirstTime = False Then tgbLR.SetSelectedButton(mapState.Get("LR")) tgbFrutis.SetSelectedButton(mapState.Get("Fruits")) Else mapState.Initialize End If I have updated the modified example "ToggleButtonExample_2.zip" in the first post. Last edited: Apr 3, 2018 Upvote 0
Erel said: It is better to post the solution so this thread can help others... Click to expand... Solution was as follows: Step 1: Declared a MAP variable Sub Process_Globals Code: Copy Private mapState As Map Step 2: Save the state in Sub Activity_Pause Code: Copy Sub Activity_Pause (UserClosed As Boolean) mapState.Put("LR", tgbLR.GetCurrentButtonName) mapState.Put("Fruits", tgbFrutis.GetCurrentButtonName) End Sub Step 3: In Sub Activity_Create, initialize the mapState if FirstTime was True or Get & Set the State if False Code: Copy If FirstTime = False Then tgbLR.SetSelectedButton(mapState.Get("LR")) tgbFrutis.SetSelectedButton(mapState.Get("Fruits")) Else mapState.Initialize End If I have updated the modified example "ToggleButtonExample_2.zip" in the first post.