protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_quiz);

    tv=(TextView)findViewById(R.id.tvque);
    btnNext=(Button)findViewById(R.id.btnNext);
    rg=(RadioGroup)findViewById(R.id.radioGroup1);
    rb1=(RadioButton)findViewById(R.id.radio1);
    rb2=(RadioButton)findViewById(R.id.radio2);
    rb3=(RadioButton)findViewById(R.id.radio3);
    rb4=(RadioButton)findViewById(R.id.radio4);

    tv.setText(questions[flag]);
    rb1.setText(options[0]);
    rb2.setText(options[1]);
    rb3.setText(options[2]);
    rb4.setText(options[3]);

    btnNext.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
    RadioButton answer=(RadioButton)findViewById(rg.getCheckedRadioButtonId());
    String ansText=answer.getText().toString();
    if(ansText.equalsIgnoreCase(ans[flag]))  <warning 
message===*'answer.getText()' may produce java.lang.NullPointerException'*
    {
        correct++;
    }
    else
    {
        wrong++;
    }
    flag++;

    if (flag<questions.length)
    {
        tv.setText(questions[flag]);
        rb1.setText(options[flag*4]);
        rb2.setText(options[(flag*4)+1]);
        rb3.setText(options[(flag*4)+2]);
        rb4.setText(options[(flag*4)+3]);
    }
    else
    {
        if(SecondActivity.tbflag)
        {
            score=correct-wrong;
        }
        else
        {
            score=correct;
        }

-- 
You received this message because you are subscribed to the Google Groups 
"Android Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/android-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/android-developers/2ec77be2-bbcd-4de4-beaa-747d915eb9e9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to