This may be a silly question, but I am struck halfway when I tried to create a simple app with a checkbox. When I use the checkbox to show and hide a single text, this works fine. But if it's for a second text, the app crashes. I wanted to hide one text and show another when the checkbox is clicked.
Here is the code
if (isChecked) {
txtHelloWorld.setVisibility(View.VISIBLE);
txtHelloWorldChecked.setVisibility(View.INVISIBLE);
} else {
txtHelloWorld.setVisibility(View.INVISIBLE);
txtHelloWorldChecked.setVisibility(View.VISIBLE);
}
}
Aucun commentaire:
Enregistrer un commentaire