Visible and invisible with a checkbox
i have a screen with 5 lines.each line has 3 editTexts.after the 5th line there is a checkbox and below it another line with 3 e开发者_运维百科dittexts.i would like,the 6th line to be invisible when i firstly open my app,and when the users checks the checkbox,the line to appear.is this possible?thanks
final CheckBox checkbox = (CheckBox) findViewById(R.id.box);
checkbox.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// Perform action on clicks, depending on whether it's now checked
if (((CheckBox) v).isChecked()) {
?????????????
} else {
???????????
}
}
});
In your layout xml file add
android:visibility="gone"
to the View that have to be hidden at startup.
Then in your code:
myHiddenView.setVisibility(View.VISIBLE);
to make it visible.
精彩评论