-4

I have checkboxes in my activity A.

I want to know is that if a user checks one of the given box, then I would like to link that to another activity so as when a user checks the box he goes to that activity B, similarly all the other boxes are linked to different activities.

I tried the code for intent in buttons but that doesn't seem to work. If i can get the particular code and the imports, that would be very helpful thanks in advance.

public void onClick(View view){
Intent i = new Intent(this, 2nd java.class);
startActivity(i);
}

I use the above one for buttons.

AndiGeeky
  • 11,266
  • 6
  • 50
  • 66
Rohan Paul
  • 11
  • 4

2 Answers2

1

You need your code to add on below listener :

 yourCheckboxView.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(RadioGroup group, int checkedId) {
            if (isChecked){
                   Intent i = new Intent(this, 2nd java.class);
                   startActivity(i);
            }
        }

    });

Thanks..!!

AndiGeeky
  • 11,266
  • 6
  • 50
  • 66
0
CheckBox chk= (CheckBox) findViewById(R.id.checkBox1);
    chk.setOnCheckedChangeListener(new OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(CompoundButton arg0, boolean arg1) {
            Intent myIntent = new Intent(FirstActivity.this,
                    SecondActivity.class);
            FirstActivity.this.startActivity(myIntent);

        }
    });