我创建了3个textviews(utilities,bmi,bmr)。如果我点击实用程序,bmi和bmr应该切换(隐藏/显示)。如何实现这一点。提前谢谢
答案 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);
}
}
);