开发者

Android checkbox ui change

How can I have a checkbox in my ui alter my ui live? For example, if the box is unchecked I want a spinner to be displayed, and if the box is checked I want a text box to be displayed in place of the spinner. I know how to create the checkbox and check its status but I don't know how to hide and reveal other e开发者_如何学Clements in an activity.


You need to register an OnClickListener for the checkbox.

http://developer.android.com/reference/android/view/View.OnClickListener.html


If you add your switchable layout inside a LinearLayout or RelativeLayout or similiar, you can easily toggle the visibility.

LinearLayout ll = (LinearLayout) findViewById(R.id.myLinearLayout);
ll.setVisibility(View.GONE);

In you XML you should set the attribute android:visibility="gone" and change it at runtime.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜