setEnabledでtrueだとbuttonを押せる。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | private Button startButton; private Button stopButton; private Button resetButton; @Override protected void onCreate(Bundle savedInstanceState) { super .onCreate(savedInstanceState); setContentView(R.layout.activity_main); startButton = (Button) findViewById(R.id.startButton); stopButton = (Button) findViewById(R.id.stopButton); resetButton = (Button) findViewById(R.id.resetButton); setButtonState( true , false , false ); } public void setButtonState( boolean start, boolean stop, boolean reset){ startButton.setEnabled( true ); stopButton.setEnabled( false ); resetButton.setEnabled( false ); } |