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 elements in an activity.
2 Answers
You need to register an OnClickListener for the checkbox.
http://developer.android.com/reference/android/view/View.OnClickListener.html
Comments
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.