Reputation: 5286
Hey all, so I have a start and a stop button. What I would like to happen is once the start button is clicked, it disappears and the stop button shows up right in the spot of the start button so that the stop button is able to be clicked. Is this done by switch statements?
//Start Button
btnstart.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
...
}
});
//Stop Button
btnstop.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
...
}
}
});
Upvotes: 0
Views: 235
Reputation: 11916
Try setVisibility with the two buttons adjacent in your layout:
//Start Button
btnstart.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
btnstart.setVisibility(View.GONE);
btnstop.setVisibility(View.VISIBLE);
}
});
//Stop Button
btnstop.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
btnstop.setVisibility(View.GONE);
btnstart.setVisibility(View.VISIBLE);
}
}
});
Upvotes: 5