HI everyone i am new to android programming just want to open new activity by selecting one of the radio button and then clicking on the submit button, just want to know how to link new activity to radiobutton and how it will intent by clicking on submitbutton?
Asked
Active
Viewed 3,360 times
-4
-
Check out starting an activity at official link: https://developer.android.com/training/basics/activity-lifecycle/starting.html – Kevin Crain Nov 22 '16 at 07:23
-
1@greenapps I think it is fair to note that writing all capital letters is considered shouting. not eveyone here are native english speakers. – sup4eli Nov 22 '16 at 07:24
-
Check out radio button at official link: https://developer.android.com/guide/topics/ui/controls/radiobutton.html – Kevin Crain Nov 22 '16 at 07:24
-
2you may not link an activity to radio button but choose which activity to launch base on the radio button is chosen while clicking the button – SaravInfern Nov 22 '16 at 07:27
-
Why do you have the `javascript` tag? – Sajib Acharya Nov 22 '16 at 07:41
-
Possible duplicate of [How to set On click listener on the Radio Button in android](http://stackoverflow.com/questions/8323778/how-to-set-on-click-listener-on-the-radio-button-in-android) – Abhimaan Nov 22 '16 at 07:47
2 Answers
1
public class MainActivity extends Activity {
private RadioGroup radioGroup;
private RadioButton rButton1,rButton2;
private Button next;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
radioGroup=(RadioGroup)findViewById(R.id.radioGroup);
rButton1=(RadioButton)findViewById(R.id.rButton1);
rButton2=(RadioButton)findViewById(R.id.rButton2);
next=(Button)findViewById(R.id.button);
next.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(rButton1.isChecked()){
Intent intent = new Intent(context, Activity1.class);
startActivity(intent)
}else if(rButton2.isChecked()){
Intent intent = new Intent(context, Activity2.class);
startActivity(intent)
}
}
});
}
}

SaravInfern
- 3,338
- 1
- 20
- 44
0
Implement an radio button in your activity and in onClickListener of submit button get the value of radio button selected and if it matches your requirement open your new activity using intent...
final RadioButton reli = (RadioButton) findViewById(R.id.radio5);
final Button go = (Button) findViewById(R.id.button1);
go.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (reli.isChecked()) {
Intent intents= new Intent(current_class.this, target_activity_class.class);
startActivity(intents);
}

raasesh
- 161
- 11
-
-
@SaravInfern, wrong. The answer does not have to have a code sample. – Vladyslav Matviienko Nov 22 '16 at 07:34
-