Skip to content Skip to sidebar Skip to footer

How To Use Visible And Invisible For A Button In Android

I want to make a button invisible, when i click another button then the invisible button will become visible and then perform onClick() actions on the visible button. What onClick(

Solution 1:

DONT USE -

donebutton.setVisibility(4);

Instead use the static constants for this:

donebutton.setVisibility(View.VISIBLE);

What exactly means

done.setVisibility(0);

Isn't is supposed to be

donebutton.setVisibility(View.GONE);

Solution 2:

Here you go:

ButtontheButton= (Button)findViewById(R.id.theButton);
theButton.setVisibility(View.VISIBLE);
theButton.setBackgroundColor(Color.TRANSPARENT);

phoneButton.setOnClickListener(newOnClickListener()
{ 
 @OverridepublicvoidonClick(View v)
 {
  // DO STUFF
 }
});

Solution 3:

Hopefully this can help you to hide the buttons as well as show the buttons if they are hidden. You need to have three buttons in your layout file in order to follow this example.

Buttonb3= (Button) findViewById(R.id.button3);
     @OverridepublicvoidonClick(View v) {
                        // TODO Auto-generated method stubif (b1.isShown() && b2.isShown()) {
                            b1.setVisibility(View.GONE);
                            b2.setVisibility(View.GONE);

                        } else {
                            b1.setVisibility(View.VISIBLE);
                            b2.setVisibility(View.VISIBLE);
                        }
                    }
                });

Solution 4:

Try onTouch() instead of onClick(): Clickable TextView in Android

Post a Comment for "How To Use Visible And Invisible For A Button In Android"