기본
/**
* 테스트 모듈 발행 case 라디오버튼 제어 리스너
*/
private RadioGroup.OnCheckedChangeListener onCheckedChangeListenerSub = new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
String moduleCase = "";
if (checkedId == R.id.rg_register_doc_title1_sub1) {
moduleCase = getString(R.string.rg_register_doc_title1_sub1);
} else if (checkedId == R.id.rg_register_doc_title1_sub2) {
moduleCase = getString(R.string.rg_register_doc_title1_sub2);
} else if (checkedId == R.id.rg_register_doc_title1_sub3) {
moduleCase = getString(R.string.rg_register_doc_title1_sub3);
} else if (checkedId == R.id.rg_register_doc_title1_sub4) {
moduleCase = getString(R.string.rg_register_doc_title1_sub4);
}
commonData.setSubTitle1(moduleCase);
}
};
2개의 라디오 버튼 리스너
/**
* 테스트 모듈 발행 case 라디오버튼1 제어 리스너
*/
private RadioGroup.OnCheckedChangeListener onCheckedChangeListenerSub1 = new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
String moduleCase = "";
if (checkedId != -1) {
rgRegisterDocTitle1Sub2.setOnCheckedChangeListener(null);
rgRegisterDocTitle1Sub2.clearCheck();
rgRegisterDocTitle1Sub2.setOnCheckedChangeListener(onCheckedChangeListenerSub2);
if (checkedId == R.id.rg_register_doc_title1_sub1_1) {
moduleCase = getString(R.string.rg_register_doc_title1_sub1);
} else if (checkedId == R.id.rg_register_doc_title1_sub1_2) {
moduleCase = getString(R.string.rg_register_doc_title1_sub2);
}
} else {
if (checkedId == R.id.rg_register_doc_title1_sub2_1) {
moduleCase = getString(R.string.rg_register_doc_title1_sub3);
} else if (checkedId == R.id.rg_register_doc_title1_sub2_2) {
moduleCase = getString(R.string.rg_register_doc_title1_sub4);
}
}
commonData.setSubTitle1(moduleCase);
}
};
/**
* 테스트 모듈 발행 case 라디오버튼2 제어 리스너
*/
private RadioGroup.OnCheckedChangeListener onCheckedChangeListenerSub2 = new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
String moduleCase = "";
if (checkedId != -1) {
rgRegisterDocTitle1Sub1.setOnCheckedChangeListener(null);
rgRegisterDocTitle1Sub1.clearCheck();
rgRegisterDocTitle1Sub1.setOnCheckedChangeListener(onCheckedChangeListenerSub1);
if (checkedId == R.id.rg_register_doc_title1_sub2_1) {
moduleCase = getString(R.string.rg_register_doc_title1_sub3);
} else if (checkedId == R.id.rg_register_doc_title1_sub2_2) {
moduleCase = getString(R.string.rg_register_doc_title1_sub4);
}
} else {
if (checkedId == R.id.rg_register_doc_title1_sub1_1) {
moduleCase = getString(R.string.rg_register_doc_title1_sub1);
} else if (checkedId == R.id.rg_register_doc_title1_sub1_2) {
moduleCase = getString(R.string.rg_register_doc_title1_sub2);
}
}
commonData.setSubTitle1(moduleCase);
}
};
리스너 등록
rgRegisterDocTitle1Sub1.clearCheck();
rgRegisterDocTitle1Sub1.setOnCheckedChangeListener(onCheckedChangeListenerSub1);
rgRegisterDocTitle1Sub2.clearCheck();
rgRegisterDocTitle1Sub2.setOnCheckedChangeListener(onCheckedChangeListenerSub2);
반응형
'Platform > Android' 카테고리의 다른 글
[DialogFragment] width, height 지정하기 (0) | 2020.06.19 |
---|---|
[RadioButton] CustomRadioButton (0) | 2020.06.12 |
[AAPT] (0) | 2020.06.08 |
[RecyclerView] (0) | 2020.06.08 |
[Concept] (0) | 2020.06.08 |