Show/hide views with checkbox
<p>I want to show or hide some elements (textviews and edittexts) with checkbox. I set their visibility to gone in layout file. Showing them when user checks the box works, but the when user unchecks it, they don't hide. (android 1.5 and 1.6)</p>

<p>My code:</p>

<pre><code>cb=(CheckBox)findViewById(R.id.cek);

cb.setOnClickListener(new OnClickListener() {  // checkbox listener
    public void onClick(View v) {
        // Perform action on clicks, depending on whether it's now checked
        if (((CheckBox) v).isChecked()) {
            tv1.setVisibility(0);  //visible==0
            et3.setVisibility(0);
        } else if (((CheckBox) v).isChecked() == false) {
            tv1.setVisibility(2); //gone=2  
                et3.setVisibility(2);
        }
    }
});
</code></pre>
