3
I’m developing a quiz game in Android Studio with 10 activities. For each question I have only two alternatives where there would be 1 for the chosen alternative and 0 for not chosen. I would like to put these values in a two-dimensional array. How I would implement this in my code to then count these responses and set a profile for the person?
package com.example.bruno.limites;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Toast;
public class Pergunta01 extends AppCompatActivity {
private RadioGroup rdgOpcoes;
private Intent it;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.pergunta01);
rdgOpcoes = (RadioGroup) findViewById(R.id.rdgOpcoes);
it = getIntent();
}
public void responder (View botao){
RadioButton rbotao = (RadioButton) findViewById(rdgOpcoes.getCheckedRadioButtonId());
String resposta = rbotao.getText().toString();
it.setClass(this, Pergunta02.class);
int respondidas = 0;
if(respondidas > 0){
respondidas++;
Toast.makeText(this, " Questao respondida ", Toast.LENGTH_LONG ).show();
}
it.putExtra("respondidas" , respondidas);
startActivity(it);
finish();
}
}
Maybe it’s best to forget those 10 activities and only have a question/answer list in one. See if this implementation serves.
– ramaral
opa friend thanks for the help, but it did not serve I really need something basic because I don’t munjo much of android my doubt and as I implemeno an array and add these values of the radio butons to this array and each question that passes it goes adding the result
– BrunoRicardo