У меня есть два радио-групп А и Б ..Clear RadioGroup от другого в Android радио-группы
Если какой-либо один из радио-кнопки A нажата, проверенное кнопку (если таковые имеются) на B должна быть очищена, и наоборот ..
Также мне нужно, чтобы показать значение выбрать в выбран.
Я реализовал нечто подобное.
private EditText selected;
private int select = 0;
private RadioGroup Arow;
private RadioGroup Brow;
После реализации findViewById ..
Arow.setOnCheckedChangeListener(AListener);
Brow.setOnCheckedChangeListener(BListener);
слушатель Arow:
OnCheckedChangeListener AListener= new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
switch (checkedId) {
case R.id.one:
select = 1;
break;
case R.id.two:
select = 2;
break;
case R.id.three:
select = 3;
break;
default:
break;
}
if(select > 0){
selected.setText(""+ select);
}
Arow.clearCheck(); // point 1
}
};
Слушателя бровей:
OnCheckedChangeListener BListener= new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
switch (checkedId) {
case R.id.four:
select = 4;
break;
case R.id.five:
select = 5;
break;
case R.id.six:
select = 6;
break;
default:
break;
}
if(select > 0){
selected.setText(""+ select);
}
Brow.clearCheck(); // point 2
}
};
Проблемы выше код происходит сбой, если я прокомментирую вышеприведенную точку 1 d point 2, код работает, но переключатель не очищается, если мне удастся выбрать кнопки из A и B, хотя значение выбора правильно отображается в выбранном.
Edit: Logcat
01-13 15:35:05.886: E/AndroidRuntime(7561): FATAL EXCEPTION: main
01-13 15:35:05.886: E/AndroidRuntime(7561): java.lang.StackOverflowError
01-13 15:35:05.886: E/AndroidRuntime(7561): at android.text.SpannableStringBuilder.getChars(SpannableStringBuilder.java:913)
01-13 15:35:05.886: E/AndroidRuntime(7561): at android.text.TextUtils.getChars(TextUtils.java:70)
01-13 15:35:05.886: E/AndroidRuntime(7561): at android.text.method.ReplacementTransformationMethod$ReplacementCharSequence.getChars(ReplacementTransformationMethod.java:151)
01-13 15:35:05.886: E/AndroidRuntime(7561): at android.text.TextUtils.getChars(TextUtils.java:70)
01-13 15:35:05.886: E/AndroidRuntime(7561): at android.text.TextUtils.indexOf(TextUtils.java:103)
01-13 15:35:05.886: E/AndroidRuntime(7561): at android.text.StaticLayout.generate(StaticLayout.java:182)
01-13 15:35:05.886: E/AndroidRuntime(7561): at android.text.DynamicLayout.reflow(DynamicLayout.java:332)
01-13 15:35:05.886: E/AndroidRuntime(7561): at android.text.DynamicLayout.<init>(DynamicLayout.java:176)
01-13 15:35:05.886: E/AndroidRuntime(7561): at android.widget.TextView.makeSingleLayout(TextView.java:6263)
01-13 15:35:05.886: E/AndroidRuntime(7561): at android.widget.TextView.makeNewLayout(TextView.java:6161)
01-13 15:35:05.886: E/AndroidRuntime(7561): at android.widget.TextView.checkForRelayout(TextView.java:6708)
01-13 15:35:05.886: E/AndroidRuntime(7561): at android.widget.TextView.setText(TextView.java:3783)
01-13 15:35:05.886: E/AndroidRuntime(7561): at android.widget.TextView.setText(TextView.java:3641)
01-13 15:35:05.886: E/AndroidRuntime(7561): at android.widget.EditText.setText(EditText.java:94)
01-13 15:35:05.886: E/AndroidRuntime(7561): at android.widget.TextView.setText(TextView.java:3616)
01-13 15:35:05.886: E/AndroidRuntime(7561): at com.xerox.ts.ops.hsd.activity.DemoActivity$2.onCheckedChanged(DemoActivity.java:232)
01-13 15:35:05.886: E/AndroidRuntime(7561): at android.widget.RadioGroup.setCheckedId(RadioGroup.java:174)
01-13 15:35:05.886: E/AndroidRuntime(7561): at android.widget.RadioGroup.check(RadioGroup.java:168)
01-13 15:35:05.886: E/AndroidRuntime(7561): at android.widget.RadioGroup.clearCheck(RadioGroup.java:209)
01-13 15:35:05.886: E/AndroidRuntime(7561): at com.xerox.ts.ops.hsd.activity.DemoActivity$1.onCheckedChanged(DemoActivity.java:203)
01-13 15:35:05.886: E/AndroidRuntime(7561): at android.widget.RadioGroup.setCheckedId(RadioGroup.java:174)
01-13 15:35:05.886: E/AndroidRuntime(7561): at android.widget.RadioGroup.check(RadioGroup.java:168)
01-13 15:35:05.886: E/AndroidRuntime(7561): at android.widget.RadioGroup.clearCheck(RadioGroup.java:209)
01-13 15:35:05.886: E/AndroidRuntime(7561): at com.xerox.ts.ops.hsd.activity.DemoActivity$2.onCheckedChanged(DemoActivity.java:234)
01-13 15:35:05.886: E/AndroidRuntime(7561): at android.widget.RadioGroup.setCheckedId(RadioGroup.java:174)
01-13 15:35:05.886: E/AndroidRuntime(7561): at android.widget.RadioGroup.check(RadioGroup.java:168)
01-13 15:35:05.886: E/AndroidRuntime(7561): at android.widget.RadioGroup.clearCheck(RadioGroup.java:209)
01-13 15:35:05.886: E/AndroidRuntime(7561): at com.xerox.ts.ops.hsd.activity.DemoActivity$1.onCheckedChanged(DemoActivity.java:203)
01-13 15:35:05.886: E/AndroidRuntime(7561): at android.widget.RadioGroup.setCheckedId(RadioGroup.java:174)
01-13 15:35:05.886: E/AndroidRuntime(7561): at android.widget.RadioGroup.check(RadioGroup.java:168)
01-13 15:35:05.886: E/AndroidRuntime(7561): at android.widget.RadioGroup.clearCheck(RadioGroup.java:209)
01-13 15:35:05.886: E/AndroidRuntime(7561): at com.xerox.ts.ops.hsd.activity.DemoActivity$2.onCheckedChanged(DemoActivity.java:234)
01-13 15:35:05.886: E/AndroidRuntime(7561): at android.widget.RadioGroup.setCheckedId(RadioGroup.java:174)
01-13 15:35:05.886: E/AndroidRuntime(7561): at android.widget.RadioGroup.check(RadioGroup.java:168)
01-13 15:35:05.886: E/AndroidRuntime(7561): at android.widget.RadioGroup.clearCheck(RadioGroup.java:209)
01-13 15:35:05.886: E/AndroidRuntime(7561): at com.xerox.ts.ops.hsd.activity.DemoActivity$1.onCheckedChanged(DemoActivity.java:203)
01-13 15:35:05.886: E/AndroidRuntime(7561): at android.widget.RadioGroup.setCheckedId(RadioGroup.java:174)
01-13 15:35:05.886: E/AndroidRuntime(7561): at android.widget.RadioGroup.check(RadioGroup.java:168)
01-13 15:35:05.886: E/AndroidRuntime(7561): at android.widget.RadioGroup.clearCheck(RadioGroup.java:209)
01-13 15:35:05.886: E/AndroidRuntime(7561): at com.xerox.ts.ops.hsd.activity.DemoActivity$2.onCheckedChanged(DemoActivity.java:234)
01-13 15:35:05.886: E/AndroidRuntime(7561): at android.widget.RadioGroup.setCheckedId(RadioGroup.java:174)
01-13 15:35:05.886: E/AndroidRuntime(7561): at android.widget.RadioGroup.check(RadioGroup.java:168)
01-13 15:35:05.886: E/AndroidRuntime(7561): at android.widget.RadioGroup.clearCheck(RadioGroup.java:209)
01-13 15:35:05.886: E/AndroidRuntime(7561): at com.xerox.ts.ops.hsd.activity.DemoActivity$1.onCheckedChanged(DemoActivity.java:203)
01-13 15:35:05.886: E/AndroidRuntime(7561): at android.widget.RadioGroup.setCheckedId(RadioGroup.java:174)
01-13 15:35:05.886: E/AndroidRuntime(7561): at android.widget.RadioGroup.check(RadioGroup.java:168)
01-13 15:35:05.886: E/AndroidRuntime(7561): at android.widget.RadioGroup.clearCheck(RadioGroup.java:209)
01-13 15:35:05.886: E/AndroidRuntime(7561): at com.xerox.ts.ops.hsd.activity.DemoActivity$2.onCheckedChanged(DemoActivity.java:234)
01-13 15:35:05.886: E/AndroidRuntime(7561): at android.widget.RadioGroup.setCheckedId(RadioGroup.java:174)
01-13 15:35:05.886: E/AndroidRuntime(7561): at android.widget.RadioGroup.check(RadioGroup.java:168)
01-13 15:35:05.886: E/AndroidRuntime(7561): at android.widget.RadioGroup.clearCheck(RadioGroup.java:209)
01-13 15:35:05.886: E/AndroidRuntime(7561): at com.xerox.ts.ops.hsd.activity.DemoActivity$1.onCheckedChanged(DemoActivity.java:203)
01-13 15:35:05.886: E/AndroidRuntime(7561): at android.widget.RadioGroup.setCheckedId(RadioGroup.java:174)
01-13 15:35:05.886: E/AndroidRuntime(7561): at android.widget.RadioGroup.check(RadioGroup.java:168)
01-13 15:35:05.886: E/AndroidRuntime(7561): at android.widget.RadioGroup.clearCheck(RadioGroup.java:209)
01-13 15:35:05.886: E/AndroidRuntime(7561): at com.xerox.ts.ops.hsd.activity.DemoActivity$2.onCheckedChanged(DemoActivity.java:234)
01-13 15:35:05.886: E/AndroidRuntime(7561): at android.widget.RadioGroup.setCheckedId(RadioGroup.java:174)
01-13 15:35:05.886: E/AndroidRuntime(7561): at android.widget.RadioG
можно ли увидеть ваш логарифм? – rahul