I have gone through many articles and found similar, but have not found any that have allowed me to fix the issue.
I am trying to create a random number generator and I cannot get the random number to get into the text field. This seems so simple and I'm not sure what is going on. The "setText" is constantly throwing an error "Cannot resolve method 'setText(Java.lang.String)"
The code within my random might be a little odd. I have been trying different things to make it work and this is the most recent attempt.
private Randomizer mRandomizer = new Randomizer();
Button rollButton;
GridLayout gridLayout;
Spinner fourspinner;
Spinner sixspinner;
Spinner eightspinner;
Spinner tenspinner;
Spinner twentyspinner;
Spinner hundredspinner;
TextView resultText;
Random randDice;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
rollButton = (Button)findViewById(R.id.rollButton);
gridLayout = (GridLayout)findViewById(R.id.gridLayout);
fourspinner = (Spinner)findViewById(R.id.fourspinner);
sixspinner = (Spinner)findViewById(R.id.sixspinner);
eightspinner = (Spinner)findViewById(R.id.eightspinner);
tenspinner = (Spinner)findViewById(R.id.tenspinner);
twentyspinner = (Spinner)findViewById(R.id.twentyspinner);
hundredspinner = (Spinner)findViewById(R.id.hundredspinner);
resultText = (TextView)findViewById(R.id.resultText);
View.OnClickListener listener = new View.OnClickListener() {
@Override
public void onClick(View v) {
// click the Button!
String resultText = "";
randDice = new Random();
for(int i = 0; i < 10; i++){
resultText += String.valueOf(randDice.nextInt()) + "\n";
}
resultText.setText(""+resultText);
//resultText.(diceRoll);
}
};
rollButton.setOnClickListener(listener);
}