How can I put a button to make it visible?

Asked

Viewed 413 times

1

How can I click a button and make the other button visible??

Button vibrar;

 cor = (Button) findViewById(R.id.cores);

 public void clica (View View){
    cor.setVisibility(View.VISIBLE);
}
  • In what language? C# Java ???

  • The language is Java.

  • 1

    You have to create a OnClickListener to receive the button click, through the method SetOnClickListener.

  • You inserted the onclick in the button vibrate in the xml file, correct? But vc is setting the id, as you did in the color button ? vibrar = (Button) findViewById(R.id.vibrar);

2 answers

1


What you lack is having one Listener on the button vibrar and in this Listener change the visibility of the button cor. For example:

Button vibrar = (Button) findViewById(R.id.vibrar);
Button cor = (Button) findViewById(R.id.cores);

vibrar.setOnClickListener(new View.OnClickListener(){

    @Override
    public void onClick(View view) {
        cor.setVisibity(View.VISIBLE);
    }
});
  • Thank you so much for your help

-1

I think that solves.

Button bt1 = findViewById(R.id.bt1);
Button bt2 = findViewById(R.id.bt2);

bt1.setOnclickListerner(new ... {
   bt2.setVisibility("gone");
});

It’s only the base, you have to fix it... You don’t want it all right.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.