選択したラジオボタンのテキストを選択時に次のラジオボタンに送信しようとしています
FirstActivity.java
public class FirstActivity extends Activity {
RadioButton carl;
RadioButton max;
RadioGroup RG;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.first_activity);
RG=(RadioGroup) findViewById(R.id.RadioButtonGroupID);
carl=(RadioButton) findViewById(R.id.CarlRadioButtonID);
max=(RadioButton) findViewById(R.id.MaxRadioButtonID);
RG.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
// TODO Auto-generated method stub
Intent INT=new Intent(FirstActivity.this,SecondActivity.class);
if(checkedId==R.id.CarlRadioButtonID)
{
INT.putExtra("REST", carl.getText());
}
else if (checkedId==R.id.MaxRadioButtonID)
{
INT.putExtra("REST", max.getText());
}
startActivity(INT);
}
});
}
}
SecondActivity.java
public class SecondActivity extends Activity {
EditText RecievedText;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.second_activity);
String RECIEVEDINTENT=getIntent().getStringExtra("REST");
RecievedText=(EditText) findViewById(R.id.RecievedText);
RecievedText.setText(RECIEVEDINTENT);
}
}
ログ::
10-12 20:09:02.846: E/AndroidRuntime(455): FATAL EXCEPTION: main
10-12 20:09:02.846: E/AndroidRuntime(455): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.radiobutton/com.example.radiobutton.SecondActivity}: java.lang.ClassCastException: android.widget.TextView
10-12 20:09:02.846: E/AndroidRuntime(455): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
10-12 20:09:02.846: E/AndroidRuntime(455): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
10-12 20:09:02.846: E/AndroidRuntime(455): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
10-12 20:09:02.846: E/AndroidRuntime(455): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
10-12 20:09:02.846: E/AndroidRuntime(455): at android.os.Handler.dispatchMessage(Handler.java:99)
10-12 20:09:02.846: E/AndroidRuntime(455): at android.os.Looper.loop(Looper.java:123)
10-12 20:09:02.846: E/AndroidRuntime(455): at android.app.ActivityThread.main(ActivityThread.java:3683)
10-12 20:09:02.846: E/AndroidRuntime(455): at java.lang.reflect.Method.invokeNative(Native Method)
10-12 20:09:02.846: E/AndroidRuntime(455): at java.lang.reflect.Method.invoke(Method.java:507)
10-12 20:09:02.846: E/AndroidRuntime(455): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
10-12 20:09:02.846: E/AndroidRuntime(455): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
10-12 20:09:02.846: E/AndroidRuntime(455): at dalvik.system.NativeStart.main(Native Method)
10-12 20:09:02.846: E/AndroidRuntime(455): Caused by: java.lang.ClassCastException: android.widget.TextView
10-12 20:09:02.846: E/AndroidRuntime(455): at com.example.radiobutton.SecondActivity.onCreate(SecondActivity.java:18)
10-12 20:09:02.846: E/AndroidRuntime(455): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
10-12 20:09:02.846: E/AndroidRuntime(455): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
マニフェストですべての活動を宣言しました
ログエラーが発生しています