Beispiel #1
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.science);
    radioButton1 = (RadioButton) findViewById(R.id.option1);
    radioButton2 = (RadioButton) findViewById(R.id.option2);
    radioButton3 = (RadioButton) findViewById(R.id.option3);
    radioButton4 = (RadioButton) findViewById(R.id.option4);
    toasttext = (TextView) findViewById(R.id.toasttext);
    question = (TextView) findViewById(R.id.question);
    rgroup = (RadioGroup) findViewById(R.id.rgroup);
    result1 = (TextView) findViewById(R.id.result1);
    next = (Button) findViewById(R.id.next);
    next.setOnClickListener(this);
    finish = (Button) findViewById(R.id.finish);
    finish.setOnClickListener(this);

    data = new EnterData();
    gt = new GetData();
    data = gt.getDataForScience();
    String option1 = data.getOption1().toString();
    String option2 = data.getOption2().toString();
    String option3 = data.getOption3().toString();
    String option4 = data.getOption4().toString();
    answer = data.getAnswer().toString();

    question.setText(data.getQuestion().toString());
    radioButton1.setText(option1);
    radioButton2.setText(option2);
    radioButton3.setText(option3);
    radioButton4.setText(option4);
  }
Beispiel #2
0
  @Override
  public void onClick(View view) {

    if ((view.getId() == R.id.next)) {
      radioButton1.setEnabled(true);
      radioButton2.setEnabled(true);
      radioButton3.setEnabled(true);
      radioButton4.setEnabled(true);

      radioButton1.setChecked(false);
      radioButton2.setChecked(false);
      radioButton3.setChecked(false);
      radioButton4.setChecked(false);
      data = new EnterData();
      gt = new GetData();
      data = gt.getDataForScience();
      String option1 = data.getOption1().toString();
      String option2 = data.getOption2().toString();
      String option3 = data.getOption3().toString();
      String option4 = data.getOption4().toString();
      answer = data.getAnswer().toString();

      question.setText(data.getQuestion().toString());
      radioButton1.setText(option1);
      radioButton2.setText(option2);
      radioButton3.setText(option3);
      radioButton4.setText(option4);
      // Toast.makeText(this, "Total Right Answer"+r+"Total Worng Answer"+w, 2).show();

    }

    if (view.getId() == R.id.finish) {
      Intent intent = new Intent();
      intent.setClass(this, MainActivity.class);
      Toast.makeText(this, "Start next activity", 2).show();
      startActivity(intent);
    }
  }