Android - can not get resources from XML -
android - resources xml
hi,
i developing android app quiz game, game has 24 questions, , each question has string(question) , 4 imagebutton(answer), when user select correctimagebutton`, go next question.
but problem is, after selecting first correct answer, screen refreshes new question , new set of images, freezes there, , no matter click, not go next question. have attached code , appreciated!!
public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_new_game); // set variables int fourimageid[] = { r.id.1_4a, r.id.1_4b,r.id.1_4c, r.id.1_4d }; questiontext = (textview) findviewbyid(r.id.question1); questionlist = getresources().getstringarray(r.array.question); correctansweridlist = listofimages.getlistofcorrectimages(); imageidlist = listofimages.getlistofimages(); //two dimension array // give values 4 image buttons (int = 0; < 4; i++) { fourimages[i] = (imagebutton) findviewbyid(fourimageid[i]); final int temp = fourimageid[i]; fourimages[i].setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { if (temp==correctansweridlist[index]){ questiontext.settext(questionlist[index]); (int = 0; < imageidlist[index].length; i++) { fourimages[i].setimageresource(imageidlist[index][i]);} index++; } } });}
your temp variable never changes after button click listeners set. because of this, if (temp==correctansweridlist[index]) statement execute once.
Comments
Post a Comment