I am having a problem when I update a certain field in my SQL database and then hitting the back button, back to my gridview (in my Level class). The intention is that I have a image and a text in a gv item, and I want the text to be updated if a user gave a correct answer:
//in my custom adapter:
//...
if (mView != null) {
int correctAnswer = getItem(position).getAnswerCorrect();
if(correctAnswer == 1) { text.setText("yea"); } else { text.setText("too bad"); }
}
If you click an item you will get to the Answer.java:
if (qAnswer.equals(userAnswer)) {
Toast.makeText(getApplicationContext(), ("Answer Correct"),
Toast.LENGTH_SHORT).show();
//update database:
myDbHelper.updateAnswerCorrect((int)id, level);
} else {
Toast.makeText(getApplicationContext(), ("Wronggggg"),
Toast.LENGTH_SHORT).show();
}
The strange thing is that when I go to the main screen and start Level.java again(Answer -> Level -> Main -> Level), it is displayed on the right way. How come I cant see it if I just go back one screen back to the gridview (Answer -> Level)?
I tried to put this in my Level class but it doesnt seem to work:
@Override
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
myAdapter.notifyDataSetChanged();
}