Note that there are some explanatory texts on larger screens.

plurals
  1. POJava: Quiz android app - adding more questions
    text
    copied!<p>I am making a <em>very</em> basic quiz app in Eclipse. Right now, it only has one question. What I want to do, is to show a new question after you answer the first one, and be able to add as many questions as I want. Preferably, I want the next question to appear X seconds after answering one question, but as I have no idea how difficult this is I am open for anything. If anyone could point me in the right direction on what I should do to be able to add more questions, I would really appreciate it. Heres's what I have so far:</p> <pre><code>package com.example.quizuke3; import android.os.Bundle; import android.os.Vibrator; import android.app.Activity; import android.content.Context; import android.view.Menu; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.TextView; public class MainActivity extends Activity implements OnClickListener{ Button button1; Button button2; Button button3; int score =0; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); button1 = (Button) findViewById(R.id.option1); button2 = (Button) findViewById(R.id.option2); button3 = (Button) findViewById(R.id.option3); button1.setOnClickListener(this); button2.setOnClickListener(this); button3.setOnClickListener(this); } @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.activity_main, menu); return true; } @Override public void onClick(View v) { TextView result = (TextView) findViewById(R.id.result); if(button1.equals(v)){ score ++; result.setText("Correct! Score: "+score); } else if(button2.equals(v)){ result.setText("Wrong! Score: "+score); } else if(button3.equals(v)){ result.setText("Wrong! Score: "+poeng); } } } </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