-4

im using android studio and im making an app but i have this problem when i pass the variable from my main to the class, my app crash.

its show me a massage that the app has stopped

this is how i pass the variable

 bravo b = new bravo();
        b.updatetext(Correctcounter);

and this is my method in the class

public void updatetext(int x) {
   TextView scoreView = (TextView)findViewById(R.id.score);
   scoreView.setText(""+x);
}

1 Answers1

0

You can't access views from classes that are not UI.

You should never access a view from a custom class.

Views must be accessed from Activity or Fragment!

Change your logic to match this requirement.

Eduardo Herzer
  • 1,683
  • 14
  • 22