标签:
<Button android:id="@+id/btnTest" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Button" /> <TextView android:id="@+id/myTestText" android:layout_width="fill_parent" android:layout_height="30dp" android:text="welcome" android:visibility="gone"/>
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
textview.setVisibility(textview.getVisibility() == View.VISIBLE ? View.GONE : View.VISIBLE);
或者
if(textview.getVisibility() == View.VISIBLE)
textview.setVisibility(View.GONE);
else
textview.setVisibility(View.VISIBLE);
}
});
[Android]使用button切换TextView可见和不可见
标签:
原文地址:http://www.cnblogs.com/dreamos/p/5068272.html