Note that there are some explanatory texts on larger screens.

plurals
  1. POandroid - How to enable a next level on a Quiz?
    text
    copied!<p>I'm new to Android app development, I'm doing a quiz app, that has categories and levels, and I have to leave only the first level of each category enabled, the next level is enabled when the user answers the question correctly, but, I don't know how to do this. Could you help me? P.S.: My database has three tables: category, level and questions. I already got it show the questions to the user and pass the questions. Below is my code:</p> <pre><code>public void verifyAnswer(String answer){ if(qCurrent.getAnswer().equals(answer)){ if(qid&lt;5){ qCurrent = qList.get(qid); setQuestions(); } else{ showMsgWin(); //here the code to unlock the next level Button level2 = (Button)findViewById(R.id.imgBtnNivel2); level2.setEnabled(true); } } else { showMsgLose(); } } </code></pre> <p>My activityLevels:</p> <pre><code> ImageButton btnNivel1 = (ImageButton)findViewById(R.id.imgBtnNivel1); ImageButton btnNivel2 = (ImageButton)findViewById(R.id.imgBtnNivel2); ImageButton btnNivel3 = (ImageButton)findViewById(R.id.imgBtnNivel3); ImageButton btnNivel4 = (ImageButton)findViewById(R.id.imgBtnNivel4); ImageButton btnNivel5 = (ImageButton)findViewById(R.id.imgBtnNivel5); ImageButton btnNivel6 = (ImageButton)findViewById(R.id.imgBtnNivel6); btnNivel1.setEnabled(true); btnNivel2.setEnabled(false); btnNivel3.setEnabled(false); btnNivel4.setEnabled(false); btnNivel5.setEnabled(false); btnNivel6.setEnabled(false); </code></pre> <p>Error:</p> <pre><code>10-06 03:56:15.382: E/AndroidRuntime(338): FATAL EXCEPTION: main 10-06 03:56:15.382: E/AndroidRuntime(338): java.lang.NullPointerException </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload