Android textview隐藏显示切换

时间:2015-03-07 15:12:49

标签: android textview toggle

我创建了3个textviews(utilities,bmi,bmr)。如果我点击实用程序,bmi和bmr应该切换(隐藏/显示)。如何实现这一点。提前谢谢

1 个答案:

答案 0 :(得分:1)

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);  
                }
            }
    );