gpt4 book ai didi

android - TextView.setVisibility 不起作用。

转载 作者:行者123 更新时间:2023-11-29 22:05:14 25 4
gpt4 key购买 nike

我试图通过代码将 TextView 设置为不可见,但它不起作用。我的 XML 声明是(在 LinearLayout 内):

    <TextView android:text="\nVideo" android:visibility="visible" 
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:id="@+id/exhibitor_profile_videoSectionLabel"
android:textAppearance="?android:attr/textAppearanceMedium"></TextView>

我的java是:

setContentView(R.layout.exhibitor_profile);
TextView vidLabel=new TextView(this);
vidLabel.findViewById(R.id.exhibitor_profile_videoSectionLabel);
vidLabel.setVisibility(View.INVISIBLE);

“不可见”调用仅在特定情况下进行,但即使我将调用移到条件之外以保证调用,TextView 仍然可见。 LogCat 在这一切期间一直保持沉默,否则我会很乐意发布它的内容。

最佳答案

您不应该创建新的 TextView。您正在尝试查找现有的:

setContentView(R.layout.exhibitor_profile);
TextView vidLabel = findViewById(R.id.exhibitor_profile_videoSectionLabel);
vidLabel.setVisibility(View.INVISIBLE);

关于android - TextView.setVisibility 不起作用。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10904108/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com