I currently have it set up so there are a couple TextViews:
One of them is updated when one button is clicked, the other button does not alter it when clicked.
The other TextViews display a number and I would like them to be altered when either one of the buttons is clicked, but currently all of the TextViews are visible and the numbers are not altered.
I would like the other TextViews (num1-num3 below) to be invisible initially, then when the user clicks either one of the buttons, the TextViews become visible and their values are updated by a method that I have written.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_name);
num1 = randNum();
num1 = alterNum(num1);
num1View = (TextView) findViewById(R.id.number1);
num1View.setText("Num1 Number: " + String.valueOf(num1));
num2 = randNum();
num2 = alterNum(num2);
num2View = (TextView) findViewById(R.id.number2);
num2View.setText("Num2 Number: " + String.valueOf(num2));
num3 = randNum();
num3 = alterNum(num3);
num3View = (TextView) findViewById(R.id.number3);
num3View.setText("Num3 Number: " + String.valueOf(num3));
// This one is always visible, the ones above should be invisible
// and appear onClick
currentNum = randNum();
myTextView = (TextView) findViewById(R.id.current_number);
myTextView.setText("Current Number: " + String.valueOf(currentNum));
okButton = (Button) findViewById(R.id.ok_button);
okButton.setOnClickListener(this);
changeButton = (Button) findViewById(R.id.change_button);
changeButton.setOnClickListener(this);
}
My onClick:
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.num_confirmation:
//do nothing
// do not let user hit buttons more than once (either case)
changeButton.setEnabled(false);
okButton.setEnabled(false);
break;
case R.id.swap_button:
currentNum = alterNum();
myTextView.setText("Current Number: " + String.valueOf(currentNum));
// do not let user hit buttons more than once (either case)
swapButton.setEnabled(false);
okButton.setEnabled(false);
break;
default:
break;
}
}
How is this done?