Try this:
edit2.isChecked()=false;
if(edit1.isChecked() && (edit2.isChecked()==false)) {
text2.setText(String1[randomInt]);
}
Question
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]);
}
OTHER TIPS
@Override
public void onItemClick(AdapterView<?> arg0, View v, int position, long arg3) {
// TODO Auto-generated method stub
CheckBox cb = (CheckBox) v.findViewById(R.id.chkSelected);
TextView tv = (TextView) v.findViewById(R.id.tvName);
// pi = (PackageInfo) arg0.getItemAtPosition(position);
cb.performClick();
if (cb.isChecked()) {
studentList.add(tv.getText().toString());
} else if (!cb.isChecked()) {
studentList.remove(tv.getText().toString());
}
}