问题描述
我的应用程序中有多种键盘背景颜色,用户可以为键盘背景选择任何颜色。我遇到的问题是,当用户选择任何颜色应用到它正在工作的键盘上,但候选视图不会改变颜色时,它的颜色与第一个主题相同。当我旋转应用程序屏幕时,候选视图颜色也会改变。你能帮我更改运行时的候选视图颜色吗?
解决方法
mCandidateView.setBackgroundResource(R.color.colorBlack);
@Override public void onStartInputView(EditorInfo attribute,boolean restarting) { super.onStartInputView(attribute,restarting);
if (modeReceived == MyConstants.Companion.getTHEME_KEYBOARD_MODE_DRAWABLE()) {
try {
int drawablePrefs =
sharedPreferences.getInt(MyConstants.Companion.getTHEME_KEYBOARD_DRAWABLE(),R.color.colorBlack);
if (mInputView != null) {
mInputView.setBackgroundResource(drawablePrefs);
mCandidateView.setBackgroundResource(drawablePrefs);
}