I have a radioGroup with 3 radioButtons. Once you select a radio button it should take you to another activity and access a specific fragment within that second activity. I have no compile or runtime errors. The issue: you can select radioButton but nothing happens. I am new to android studios and java. I would appreciate any help. Most questions are using a button to access a new activity not a radio button.
package com.example.joseph.ex51_twoactivities; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.View; import android.widget.RadioButton; public class MainActivity extends Activity implements View.OnClickListener { //EditText etMessage; RadioButton profOne; RadioButton profTwo; RadioButton profThree; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //etMessage = (EditText)findViewById(R.id.etMessage); profOne = (RadioButton)findViewById(R.id.rdProf1); profTwo = (RadioButton)findViewById(R.id.rdProf2); profThree = (RadioButton)findViewById(R.id.rdProf3); if(profOne.isChecked()) { profOne.setOnClickListener(this); } if(profTwo.isChecked()) { profTwo.setOnClickListener(this); } if(profThree.isChecked()) { profThree.setOnClickListener(this); } }
Answer
I figured it out, I shouldn’t have a conditional statement under the onCreate method.