1

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?

Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
user2736219
  • 33
  • 1
  • 7

2 Answers2

2

Try this:

edit2.isChecked()=false;

if(edit1.isChecked() && (edit2.isChecked()==false)) {
    text2.setText(String1[randomInt]);
}
Elletlar
  • 3,136
  • 7
  • 32
  • 38
Kanwaljit Singh
  • 4,339
  • 2
  • 18
  • 21
1
@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());
        }
    }
Hardik Thummar
  • 61
  • 1
  • 1
  • 4