Java 从RadioButton android传递字符串:text="@字符串/蓝色“;转到android中的下一个活动

Java 从RadioButton android传递字符串:text="@字符串/蓝色“;转到android中的下一个活动,java,android,Java,Android,我有 我试过这个 EditText editTextSignUpUserName = (EditText) findViewById(R.id.sign_up_user_name); String signUpUserName = editTextSignUpUserName.getText().toString(); intent.putExtra("username", signUpUserName); 谢谢你。好的,你就快到了。但放射组不是单选按钮。试试这个: RadioButton s

我有

我试过这个

EditText editTextSignUpUserName = (EditText) findViewById(R.id.sign_up_user_name);
String signUpUserName = editTextSignUpUserName.getText().toString();
intent.putExtra("username", signUpUserName);

谢谢你。

好的,你就快到了。但放射组不是单选按钮。试试这个:

RadioButton selectedRadioButton = (RadioButton)   findViewById(R.id.sign_up_select_colour);
String signUpColour = selectedRadioButton.getCheckedRadioButtonText().toString();
intent.putExtra("colour", signUpColour);

不客气。我将第二行更改为
colorGroup.findViewById()
,这应该会稍微快一点。为什么RadioGroup没有返回选中的RadioButton(或视图)本身的
getCheckedButton()
方法,这对我来说是一个愚蠢的问题。。。
RadioButton selectedRadioButton = (RadioButton)   findViewById(R.id.sign_up_select_colour);
String signUpColour = selectedRadioButton.getCheckedRadioButtonText().toString();
intent.putExtra("colour", signUpColour);
RadioGroup colourGroup = (RadioGroup) findViewById(R.id.sign_up_select_colour);
RadioButton button = (RadioButton) colourGroup.findViewById(colourGroup.getCheckedRadioButtonId());
String signUpColour = button.getText().toString();
intent.putExtra("gender", signUpColour);