My SharedPreferences shows only invisible text
I've generated a SharedPreferences screen in my application following instructions "by the book". Nothing special. But I get only invisible preferences on screen (both simulator and phone).
Here's the screenshots (sorry, it's link. i'm not allowed to post image): Print Screens of Properties
Notice that I tried with default Theme and also Light - No Title
Here's the code: XML/preferences.xml:
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http: //schemas. android.com/apk/res/android">
<PreferenceCategory
android:title="@string/menukad">
<CheckBoxPreference
android:key="menukad12"
android:defaultValue="false"
android:title="Nikud in the Text?"
android:summary="@string/menukad" />
<CheckBoxPreference
android:title="Checkbox Preference"
android:defaultValue="false"
android:summary="This preference can be true or false"
android:key="checkboxPref" />
</PreferenceCategory>
</PreferenceScreen>
myPreferences.java
package com.android.orvishua.mishneTorah;
import android.os.Bundle;
import android.preference.PreferenceActivity;
import android.view.KeyEvent;
public class myPreferences extends PreferenceActivity
{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
chapterSave.setReLoad(true);
}
return super.onKeyDown(keyCode, event);
}
}
Reading preferences:
public SharedPreferences myprefs;
public boolean menukad;
myprefs = PreferenceManager.getDef开发者_如何学JAVAaultSharedPreferences(getBaseContext()) ;
menukad = myprefs.getBoolean("menukad12", false);
Manifest (all other Activities are with the default style. no changes):
<activity android:name=".myPreferences" android:label="@string/app_name" />
or
<activity android:name=".myPreferences" android:theme="@android:style/Theme_Light_NoTitleBar" android:label="@string/app_name" />
Can someone help me???
Try creating your own theme in your styles.xml (if you dont have one, create it in the values folder)
For example
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="YourStyle" parent="android:Theme.Light">
<item name="android:listViewStyle">@style/Widget.ListView</item>
<item name="android:textColor">@color/your_color</item>
<item name="android:windowNoTitle">true</item>
</style>
<style name="Widget" parent="android:Widget">
</style>
<style name="Widget.ListView">
<item name="android:background">@color/white</item>
<item name="android:divider">@color/gray_division</item>
<item name="android:dividerHeight">2dip</item>
</style>
</resources>
I hope this helps
精彩评论