You need to initialize the TextView inside your onCreate () method. Your code will look something like this.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fourth);
TextView textBox = (TextView) findViewById(R.id.textView8);
double randNumber = Math.random();
int d = (int) (randNumber * 100 );
int randomInt = (int)d * 2;
textBox.setText("" + randomInt);
}
source
share