1

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 2

1

You need to register an OnClickListener for the checkbox.

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

Sign up to request clarification or add additional context in comments.

Comments

1

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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.