简体   繁体   English

设置整个盒子的可见性

[英]Set The Visibility of The Whole Box

So in my app I have a registration form used to register other users. 因此,在我的应用程序中,我有一个用于注册其他用户的注册表。 In my app I have 3 ranks (Admin, Patient, HCP). 在我的应用程序中,我有3个等级(管理员,患者,HCP)。 In the 'New HCP' form I want to hide something that is in my .xml file for the TextView. 在“ New HCP”表单中,我想隐藏.xml文件中TextView的内容。 I am well aware of setVisibilty(View.GONE); 我很清楚setVisibilty(View.GONE); but this doesn't work for my options because I have the boxes in a Constraint Layout . 但这对我的选择不起作用,因为我在“ 约束布局”中有框。

My Question is: 我的问题是:

How do I hide the whole box including its contents? 如何隐藏整个盒子及其内容?

I tried this (but it only hid the contents and left the drawable box behind: 我尝试了此操作(但它只隐藏了内容,并在后面留下了可绘制框:

TextView consent_TextView = (TextView) findViewById(R.id.Register_text_Activity_consent);
        consent_TextView.setVisibility(View.GONE);
        TextView remind_TextView = (TextView) findViewById(R.id.Register_text_Activity_remind);
        remind_TextView.setVisibility(View.GONE);

Please remember that I want to change this in Java not XML because if I do it in XML I will hide the box for everyone . 请记住,我想用Java而不是XML进行更改,因为如果用XML进行更改,我将为所有人隐藏该框 Thanks! 谢谢!

如评论中所述,您可以通过View#getParent()获得要设置可见性的框的引用,也可以通过View#setId()编程方式设置其ID,绑定它并设置其可见性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM