我的布局中有TextVIEw.我想保持它隐藏,只想在按钮点击时看到一次,我该怎么办?我的观点如下.
谢谢
<TextVIEw androID:layout_marginBottom="16dp" androID:layout_marginRight="8dp" androID:ID="@+ID/textAuthorSign" androID:layout_gravity="right" androID:text="- ABJ Abdul Kalam" androID:textStyle="italic" androID:textSize="16sp" androID:typeface="serif" androID:visibility="invisible" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" />
谢谢
解决方法:
我想你想要一个切换(正如问题标题所述)
XML文件:
<button androID:layout_height="wrap_content" androID:layout_wIDth="wrap_content" androID:text="@string/self_destruct" androID:onClick="hIDe" /> <TextVIEw androID:layout_marginBottom="16dp" androID:layout_marginRight="8dp" androID:ID="@+ID/textAuthorSign" androID:layout_gravity="right" androID:text="- ABJ Abdul Kalam" androID:textStyle="italic" androID:textSize="16sp" androID:visibility="invisible" androID:typeface="serif" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" />
Java的:
public voID hIDe(VIEw vIEw) { TextVIEw txtVIEw = (TextVIEw)findVIEwByID(R.ID.textAuthorSign); //Toggle if (txtVIEw.getVisibility() == VIEw.VISIBLE) txtVIEw.setVisibility(VIEw.INVISIBLE); else txtVIEw.setVisibility(VIEw.VISIBLE); //If you want it only one time //txtVIEw.setVisibility(VIEw.VISIBLE); }
总结 以上是内存溢出为你收集整理的如何从java隐藏/显示TextView全部内容,希望文章能够帮你解决如何从java隐藏/显示TextView所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)