我正在尝试读取我的应用程序首选项,但出现了以下错误:
设置活动:
public class Settings extends PreferenceActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
try
{
addPreferencesFromResource(R.xml.prefs);
}
catch (Exception ex)
{
Log.e("errorSettings", Log.getStackTraceString(ex));
}
}
}
首选项XML文件:
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
<PreferenceCategory android:title="General">
<SwitchPreference
android:title="Downloader"
android:defaultValue="true"
android:key="useDownloader"
android:summary="Enable to use" />
</PreferenceCategory>
</PreferenceScreen>
在应用程序清单上,我设置了这个:
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="15" />
我遇到的第一个错误是:
android.view.InflateException: Binary XML file line #4: Error inflating class SwitchPreference
提前感谢您。