yourViewThatShouldVanish

yourViewThatShouldVanish

我已经创建了3个textviews(utilities,bmi,bmr)。如果我单击Utility,bmi和bmr应该切换(隐藏/显示)。如何实现这一点。先感谢您

最佳答案

TextView utilityOne;

utilityOne.setOnClickListener(
            new View.OnClickListener() {
                @Override
                public void onClick (View v) {
                    if(yourViewThatShouldVanish.getVisibility == View.VISIBLE){
                        yourViewThatShouldVanish.setVisibility(View.GONE);
                    }
                    else{
                       yourViewThatShouldVanish.setVisibility(View.VISIBLE);
                }
            }
    );

10-08 00:06