소프트웨어/안드로이드
[Android/Kitkat] 로케일 변경 시 CheckBox 텍스트가 업데이트 되지 않는 현상 해결
이로이로
2020. 7. 13. 18:22
1) onResume에서 텍스트를 업데이트
@Override
protected void onResume() {
checkBox.setText(R.string.text);
}
2) CheckBox 상속한 Custom View에서 onRestoreInstanceState 수정
public class MyCheckbox extends CheckBox {
public IBCheckbox(Context context) {
super(context);
}
public IBCheckbox(Context context, AttributeSet attrs) {
super(context, attrs);
}
public IBCheckbox(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
public void onRestoreInstanceState(Parcelable state) {
final CharSequence text = getText(); // the text has been resolved anew
super.onRestoreInstanceState(state); // this restores the old text
setText(text); // this overwrites the restored text with the newly resolved text
}
}
참고:
Android Localization problem: Not all items in the layout update properly when switching locales
Here's the problem: When I have an activity running in the background, and I switch locales, and I switch back to the application, everything updates... EXCEPT checkboxes and radio buttons that hav...
stackoverflow.com
https://android-review.googlesource.com/c/platform/frameworks/base/+/67850
https://android-review.googlesource.com/c/platform/frameworks/base/+/67850
android-review.googlesource.com