这是代码:
final CheckBox save = (CheckBox) findVIEwByID(R.ID.checkBox); save.setonClickListener(new OnClickListener() { public voID onClick(VIEw v) { // Perform action on clicks,depending on whether it's Now checked if (((CheckBox) v).isChecked()) { nameText.setVisibility(1); editname.setVisibility(1); } else { nameText.setVisibility(0); editname.setVisibility(0); } } });
并且在相对布局内部的xml的一部分:
<linearLayout androID:ID="@+ID/linearLayout3" androID:orIEntation="horizontal" androID:layout_wIDth="fill_parent" androID:layout_height="wrap_content" androID:layout_below = "@+ID/linearLayout2"> <TextVIEw androID:ID="@+ID/text" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:text="@string/name" androID:visibility="invisible"/> <EditText androID:ID="@+ID/name" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:layout_weight="1" androID:visibility="invisible"/> <CheckBox androID:ID="@+ID/checkBox" androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:text="@string/save" /></linearLayout>
当我取消选中复选框时,我该怎么做才能使textVIEw和EditText消失?
谢谢!
解决方法 使用VIEw.VISIBLE,VIEw.INVISIBLE,VIEw.GONE来控制可见性(而不是0和1). 总结以上是内存溢出为你收集整理的Android复选框可见性问题全部内容,希望文章能够帮你解决Android复选框可见性问题所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)