I want to change one activity to another activity. It worked at the first time, But not at the next, How do I fix that?
public class Activity1 extends Activity {
RadioGroup radioGroup;
RadioButton Rd1, Rd2;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.layout_activity1);
radioGroup=(RadioGroup)findViewById(R.id.radioGroup);
Rd1=(RadioButton)findViewById(R.id.radioButton);
Rd2=(RadioButton)findViewById(R.id.radioButton2);
radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
if(Rd1.isChecked())
{
Intent intent = new Intent(getApplicationContext(), Acitivity.class);
startActivity(intent);
}
else {
if (Rd2.isChecked()) {
Intent intent1 = new Intent(getApplicationContext(), Acivity1.class);
startActivity(intent1);
}
}
}
});
}
}
I noticed that you wanted to go from Activity1 to Activity.class, you cannot do that. Change Activity.class to existing activity, ex: Activity2.class. And you need to simplify your listener: to something like this: