I am working on quiz application in android. We have created Select.java page which displays the questions and options(with radio buttons) from sqlite datab
Hmmm, just add one more member variable in UserBO to store selected answer.
Class UserBO {
private int userID;
private String userName;
private String question;
private String option1;
private String option2;
private String option3;
private int answerID;
//create getter and setters for above member variables
}
then within onclick listener of Adapter class, do like as following
radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup radioGroup,
int radioButtonID) {
switch(radioButtonID) {
case R.id.option1:
listItem.setAnswerID(1);
break;
case R.id.option2:
listItem.setAnswerID(2);
break;
}
}
});
then change your header constructor to receive userarraylist (which contains user details with answer)
ArrayList userList;
Header(Context context, AttributeSet attrs, ArrayList userALt) {
userList = userAL;
}
//on next button click
onclick() {
for(UserBO userObj: userList) {
if (userObj.getAnswerID != 0)
Log.d("AnswerID", userObj.getAnswerID);
}
}
it just like sudo code.. i hope this will help u..