androidradio-buttonitemizedoverlay

Android Itemized Overlay Alert Dialog Variable Conundrum


I am creating a quiz app and I have a custom ItemizedOverlay where I have an AlertDialog appear with Radio Buttons. It loads values from a database which is parsed in another bit of code.

I can add radio buttons to display each question and a toast appears onClick for each answer to show which was selected. However, I can't seem to make the submit button show/register which answer was selected.


Solution

  • The whichButton in your setPositiveButton OnClickListener probably refers to the submit button itself.

    Instead, declare an int answerIndex in the onTap method. Then in the onClick for the choice, set answerIndex = whichButton. Finally when you write the answer to the db, use answerIndex instead of whichButton.

    Hope this helps.