0
我试图通过PrefernceSetting更改MainActivity的BG。 Preference.xml:通过PreferencesActivity更改MainActivity
...
<CheckBoxPreference android:title="Test_bg"
android:defaultValue="false"
android:summary="Summary test_bg"
android:key="test_bg" />
...
我怎么能值转移到MainActivity?谢谢!
谢谢!但我不明白:('SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); prefs.getBoolean(“test_bg”,false);' - 我可以放入OnCreate方法吗?这个样本:RelativeLayout.setBackgroundColor(getResources()。getColor(R.color.redColor));我认为algorythm需要这样: –
If(“test_bg”== true)FrameLayout.setBackgroundColor(getResources()。 getColor(R.color.redColor)); else RelativeLayout.setBackgroundColor(getResources()。getColor(R.color.blackColor)); –
看到我编辑的答案 – Emil