I really want to know how to enable a button and move on to the next activity but my problem is that i have 2 radioGroup and i don't know where do i have to set the Intent and setEnabled(). I think i should use a conditional but i'm not sure.
Code
So far I have this code
radioGroup = findViewById(R.id.RadioGroup);
radioGroupGM = findViewById(R.id.radioGroupGM);
//Button
siguiente = findViewById(R.id.buttonSiguiente);
//RadioButton
b1 = findViewById(R.id.radioButton);
b2 = findViewById(R.id.radioButton2);
b3 = findViewById(R.id.radioButton3);
b4 = findViewById(R.id.radioButton4);
b5 = findViewById(R.id.radioButto11);
b6 = findViewById(R.id.radioButto22);
b7 = findViewById(R.id.radioButto33);
b8 = findViewById(R.id.radioButto44);
cliente = new AsyncHttpClient();
getSupportActionBar().setTitle("REPORTE");
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
//---------------------------------------------------------------------------------------
siguiente.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if( !b1.isChecked() || !b2.isChecked() || !b3.isChecked() || !b5.isChecked() ||
!b6.isChecked() || !b7.isChecked() || !b8.isChecked() ){
Toast.makeText(Inventory.this, "choose a button", Toast.LENGTH_SHORT).show();
}
}
});
//---------------------------------------------------------------------------------------
//---- -- --- --- -- THE PROBLEM --- - - - - ---- -- - -- -------
radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
if( b1.isChecked() || b2.isChecked() || b3.isChecked() || b4.isChecked() ){
siguiente.setEnabled(true); // THIS
Intent siguiente = new Intent(Inventory.this, Siguiente.class); // IS
startActivity(siguiente); // THE PROBLEM
}
}
});
radioGroupGM.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
if( b5.isChecked() || b6.isChecked() || b7.isChecked() || b8.isChecked() ){
siguiente.setEnabled(true); //THIS
Intent siguiente = new Intent(Inventory.this, Siguiente.class);// IS
startActivity(siguiente); // THE PROBLEM
}
}
});
You can check if any of the radio group has checked radio button.
also do same in your next radio group
now you can set your onclick listener for your button
i think this should solve your problem. Happy Coding!!