アプリケーションの設定で設定を変更して、プログラムでテーマを設定することに問題があります。設定のオプションをクリックして、Holo と Holo Light を切り替えたいです。
推奨事項、ソースコード、知識、リンクなどは大歓迎です、ありがとう
DashboardActivity.java
public class DashboardActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Utils.onActivityCreateSetTheme(this);
setContentView(R.layout.dashboard_layout);
if (Settings.theme.equals("Theme1")) {
Utils.changeToTheme(this, Utils.THEME_LIGHT);
}else (Settings.theme.equals("Theme2")) {
Utils.changeToTheme(this, Utils.THEME_DARK);
}
設定.java
public class Settings extends PreferenceActivity implements
OnSharedPreferenceChangeListener {
public static String theme = "Theme1";
public void onBackPressed() {
// ListPreference listPreference2 = (ListPreference) findPreference("activityPref");
ListPreference listPreference = (ListPreference) findPreference("themePref");
String currValue = listPreference.getValue();
// String currValue2 = listPreference.getValue();
// Log.d("ssss", "Value :" + currValue);
// Log.d("ssss", "Value :" + currValue2);
// activity = currValue2;
theme = currValue;
super.onBackPressed();
設定.xml
<ListPreference
android:title="Themes"
android:summary="Change the UI of the application"
android:key="themePref"
android:entries="@array/themesReturnValue"
android:entryValues="@array/themesDisplayWord"
android:defaultValue="Theme1"/>
配列.xml
<string-array name="themesReturnValue">
<item>Light</item>
<item>Dark</item>
</string-array>
<string-array name="themesDisplayWord">
<item>Theme1</item>
<item>Theme2</item>
スタイル
<style name="LightThemeAndroid" parent="android:style/Theme.Holo.Light">
</style>
<style name="DarkThemeAndroid" parent="android:style/Theme.Holo">
</style>
それが私が得たすべてです....私はそれが仕事であることを知っていますが、どんな助けも大歓迎です。ありがとうございました