how to use visible and invisible for a button in android

前端 未结 4 488
迷失自我
迷失自我 2021-02-04 06:29

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 butto

4条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-04 06:51

    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.

    Button b3 = (Button) findViewById(R.id.button3);
         @Override
                        public void onClick(View v) {
                            // TODO Auto-generated method stub
                            if (b1.isShown() && b2.isShown()) {
                                b1.setVisibility(View.GONE);
                                b2.setVisibility(View.GONE);
    
                            } else {
                                b1.setVisibility(View.VISIBLE);
                                b2.setVisibility(View.VISIBLE);
                            }
                        }
                    });
    

提交回复
热议问题