使用搜索栏我可以更改背景颜色但无法保存shanged 打开活动时的颜色
row
答案 0 :(得分:0)
你可以这样做:
SharedPreferences sharedPref = getSharedPreferences("COLOR", MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPref.edit();
// Only if you know it is a color
ColorDrawable buttonColor = (ColorDrawable) button.getBackground();
int colorId = buttonColor.getColor();
editor.putInt("color_KEY", colorId );
editor.commit();
答案 1 :(得分:0)
你可以这样做,
ColorDrawable buttonColor =(ColorDrawable)button.getBackground();
int colorId = buttonColor.getColor();
SharedPreferences sharedPref = getSharedPreferences("COLOR",MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPref.edit();
editor.putInt("color_KEY",id.toString());
editor.commit();