Android Question Database/Loading Panels words become muddled.

brianwiz12

Active Member
Licensed User
Longtime User
Hello,

So i have the following attached. This problem i thought was solved but for some reason has reared its ugly head again.

Click on Button 2. Then load episode 2. then go back to episode 1

The radio buttons are not clearing themselves. They are loaded for each panel.

I did try pnle2.removeallviews(Erel had it in another thread). It did not work for the radio button answer issue. You can see by going from 1 to 2 back to 1 click nexting it will be all muddled
 

Attachments

  • Scaling.zip
    30.9 KB · Views: 177

mangojack

Expert
Licensed User
Longtime User
I did have a look , but unfortunately cannot identify where the issue occurs. (would have liked to spend more time looking ...)

But I do believe you could fix the problem and reduce your code dramatically (and more easier to debug) by using a single episodes Panel , (pnle 1-10),
loading and answering the questions with the same panel.

Hope your able to resolve the problem.
 
Upvote 0

mangojack

Expert
Licensed User
Longtime User
Just Having another look , I think your problem lies in initializing / adding the radio buttons to the panels in the episode(1-10)_click subs.

B4X:
Sub episode1_click

   '........................................
    rbtAnswer1(0).Initialize("rbtAnswer1")
    rbtAnswer1(0).Tag = 0
    rbtAnswer1(0).TextColor = Colors.Blue
    pnle1.AddView(rbtAnswer1(0), 10dip, 60dip, 450dip, 75dip)
    rbtAnswer1(1).Initialize("rbtAnswer1")
    rbtAnswer1(1).Tag = 1
    rbtAnswer1(1).TextColor = Colors.Blue
    pnle1.AddView(rbtAnswer1(1), 10dip, 120dip, 450dip, 75dip)
    rbtAnswer1(2).Initialize("rbtAnswer1")
    rbtAnswer1(2).Tag = 2
    rbtAnswer1(2).TextColor = Colors.Blue
    pnle1.AddView(rbtAnswer1(2), 10dip, 180dip, 450dip, 75dip)
    '.......... more code

These episode?_click subs are being called from Sub spnewsrooms1_ItemClick

Each time you choose an episode from the spinner the radio buttons are re-added to the panel. If You do NOT press Next Button then choose another Episode, then return to original episode the RadioButtons just get brighter ... Pressing the Next Button then following this scenario , thats when you see Muddled Answers (2 Answers on top of each other)

Your solution is to load the radio buttons to all panels once only in Activity Create (or a called sub) ... (not in a sub that can be repeatedly called)

Or.. add the radio buttons to panels in the Designer (you have added the other views there)

Also , just to repeat , you do have a lot of duplicated code that could be removed by playing with a single Panel / views. (I'm sure it can be done).

(Even the above snippet could be reduced using a loop.... the only real variance is the .Top value = a calculation , and the .Tag = counter value)
 
Last edited:
Upvote 0

mangojack

Expert
Licensed User
Longtime User
Had some time free and was intrigued to see if there was a way to solve your problem while reducing layouts and certainly code.

Note ... It is only a Barebones Demo which shows another method to present ALL Trivia Questions using a Single Panel , therefore also reducing duplicated code.

At the very Least , it might give you ideas or different approach's that will help with your project

I have Not addressed aesthetics, scaling etc and certainly you will want some extra checks / balances etc
 

Attachments

  • TVQuiz.zip
    22.7 KB · Views: 154
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…