I try to use CheckBox
in my app. The status of checkBox
(checked/uncheked), I use in putExtra
and then in next activity, depending on the result I send a query
to database
. The problem is with multiply check.
public class Myactivity extends AppCompatActivity implements View.OnClickListener{
CheckBox mCheck1;
CheckBox mCheck2;
CheckBox mCheck3;
ImageButton mImageButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_option);
mImageButton = findViewById(R.id.button_ok_option);
mCheck1 = findViewById(R.id.checkBox1);
mCheck2 = findViewById(R.id.checkBox2);
mCheck3 = findViewById(R.id.checkBox3);
mImageButton.setOnClickListener(this);
}
@Override
public void onClick(View v) {
Intent intent = new Intent(this, Choose_meet_activity.class);
intent.putExtra("1", mCheck1.isChecked());
intent.putExtra("2", ((mCheck1.isChecked()) && (mCheck2.isChecked()));
intent.putExtra("3", mCheck2.isChecked());
startActivity(intent)
}
}
For example, if I use mCheck1 - in database searching results with "colour":"red"
,mCheck2 - "size":"big"
. When I press the Check1 - all good, all results with "red"
come to me. And the same positive result with mCheck2, that is, under any single condition. But when I pressed mCheck1 && mCheck2 - all results with color:"red"
, even if "size"
not "big"
come back to me. What is wrong?
Aucun commentaire:
Enregistrer un commentaire