How to hide a button programmatically?
You can use the following code:
playButton = (Button) findViewById(R.id.play);
playButton.setVisibility(View.VISIBLE);
playButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
//when play is clicked show stop button and hide play button
playButton.setVisibility(View.GONE);
stopButton.setVisibility(View.VISIBLE);
}
});
Try the below code -
playButton.setVisibility(View.INVISIBLE);
or -
playButton.setVisibility(View.GONE);
show it again with -
playButton.setVisibility(View.VISIBLE);