-7

Please help me what I want to do is whenever I clicked a radiobutton the variables increase it's value so i create a method like this but every time I clicked the button the app unfortunately stops.

public void verbal1(){
  verbalSc = verbalSc + 1;
    Toast.makeText(getBaseContext(), "1", Toast.LENGTH_SHORT).show();
    verScore.setText(Integer.toString(verbalSc));

}
Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
xhen
  • 51
  • 1
  • 6

1 Answers1

0

Make sure your verScore has the reference of TextView in XML.

Try this:

int verbalSc = 0;
TextView verScore;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    ...........
    .................
    verScore = (TextView) findViewById(R.id.your_textview);
}

public void verbal1(){
    verbalSc = verbalSc + 1;
    Toast.makeText(getBaseContext(), "1", Toast.LENGTH_SHORT).show();

    verScore.setText(Integer.toString(verbalSc));
}
Ferdous Ahamed
  • 21,438
  • 5
  • 52
  • 61