androidischecked

Android: If statement based on checkbox not being checked


I think this is really easy but I am fairly new to android development so thanks in advance

If the first one is checked I generate a random number for text Item 1. If both the checkboxs are checked I generate text for the second text. I was wondering what is the most efficient way to do this

Here is the snippet that I need help with

if(edit1.isChecked()){
    text1.setText(String1[randomInt]);
}

if(edit1.isChecked() && edit2.isChecked()){
    text2.setText(String1[randomInt]);
}

Obviously, the first statement will show true in both. basically is there a way to say if edit2 is false?


Solution

  • Try this:

    edit2.isChecked()=false;
    
    if(edit1.isChecked() && (edit2.isChecked()==false)) {
        text2.setText(String1[randomInt]);
    }