私は自分の好みを少し上手くしています。 IconPreferenceScreenクラスを使用して、それぞれにアイコンを追加していますが、すべてのPreferenceScreensをIconPreferenceScreenに変更すると、強制的に閉じることができます。PreferenceScreenが強制終了させるのはなぜですか?
私が示す最初の嗜好は完全に機能しますが、2番目の強制は終了します。
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:icon="http://schemas.android.com/apk/res/com.andrew.notifyme"
android:key="preference_screen"
android:title="@string/app_name_formatted">
<PreferenceCategory
android:key="test_app_category"
android:title="@string/test_text">
<com.andrew.notifyme.preferences.IconPreferenceScreen
android:key="test_app"
android:title="@string/test_text"
icon:icon="@drawable/ic_test"
android:dependency="app_enabled" >
</com.andrew.notifyme.preferences.IconPreferenceScreen>
</PreferenceCategory>
<PreferenceCategory
android:key="basic_settings_category"
android:title="@string/basic_settings_text">
<com.andrew.notifyme.preferences.IconPreferenceScreen
android:key="basic_settings_screen"
android:title="Themes"
icon:icon="@drawable/ic_test"
android:dependency="app_enabled" >
<PreferenceScreen
android:key="quick_reply_settings_screen"
android:title="@string/quick_reply_settings_text"
android:dependency="app_enabled">
<CheckBoxPreference
android:key="quick_reply_save_draft_enabled"
android:title="@string/preference_save_draft_enabled_title"
android:summaryOn="@string/preference_save_draft_enabled_summaryOn"
android:summaryOff="@string/preference_save_draft_enabled_summaryOff"
android:defaultValue="true" />
</com.andrew.notifyme.preferences.IconPreferenceScreen>
</PreferenceScreen>
</PreferenceCategory>
スタックトレース:
08-04 01:06:50.697: ERROR/AndroidRuntime(9683): FATAL EXCEPTION: main
08-04 01:06:50.697: ERROR/AndroidRuntime(9683): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.andrew.notifyme/com.andrew.notifyme.preferences.MainPreferenceActivity}: java.lang.ClassCastException: com.andrew.notifyme.preferences.IconPreferenceScreen
08-04 01:06:50.697: ERROR/AndroidRuntime(9683): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1768)
08-04 01:06:50.697: ERROR/AndroidRuntime(9683): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1784)
08-04 01:06:50.697: ERROR/AndroidRuntime(9683): at android.app.ActivityThread.access$1500(ActivityThread.java:123)
08-04 01:06:50.697: ERROR/AndroidRuntime(9683): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:939)
08-04 01:06:50.697: ERROR/AndroidRuntime(9683): at android.os.Handler.dispatchMessage(Handler.java:99)
08-04 01:06:50.697: ERROR/AndroidRuntime(9683): at android.os.Looper.loop(Looper.java:130)
08-04 01:06:50.697: ERROR/AndroidRuntime(9683): at android.app.ActivityThread.main(ActivityThread.java:3835)
08-04 01:06:50.697: ERROR/AndroidRuntime(9683): at java.lang.reflect.Method.invokeNative(Native Method)
08-04 01:06:50.697: ERROR/AndroidRuntime(9683): at java.lang.reflect.Method.invoke(Method.java:507)
08-04 01:06:50.697: ERROR/AndroidRuntime(9683): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847)
08-04 01:06:50.697: ERROR/AndroidRuntime(9683): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605)
08-04 01:06:50.697: ERROR/AndroidRuntime(9683): at dalvik.system.NativeStart.main(Native Method)
08-04 01:06:50.697: ERROR/AndroidRuntime(9683): Caused by: java.lang.ClassCastException: apps.droidnotify.preferences.IconPreferenceScreen
08-04 01:06:50.697: ERROR/AndroidRuntime(9683): at android.preference.GenericInflater.rInflate(GenericInflater.java:488)
08-04 01:06:50.697: ERROR/AndroidRuntime(9683): at android.preference.GenericInflater.rInflate(GenericInflater.java:493)
08-04 01:06:50.697: ERROR/AndroidRuntime(9683): at android.preference.GenericInflater.rInflate(GenericInflater.java:493)
08-04 01:06:50.697: ERROR/AndroidRuntime(9683): at android.preference.GenericInflater.inflate(GenericInflater.java:326)
08-04 01:06:50.697: ERROR/AndroidRuntime(9683): at android.preference.GenericInflater.inflate(GenericInflater.java:263)
08-04 01:06:50.697: ERROR/AndroidRuntime(9683): at android.preference.PreferenceManager.inflateFromResource(PreferenceManager.java:251)
08-04 01:06:50.697: ERROR/AndroidRuntime(9683): at android.preference.PreferenceActivity.addPreferencesFromResource(PreferenceActivity.java:262)
08-04 01:06:50.697: ERROR/AndroidRuntime(9683): at com.andrew.notifyme.preferences.MainPreferenceActivity.onCreate(MainPreferenceActivity.java:103)
08-04 01:06:50.697: ERROR/AndroidRuntime(9683): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
08-04 01:06:50.697: ERROR/AndroidRuntime(9683): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1722)
08-04 01:06:50.697: ERROR/AndroidRuntime(9683): ... 11 more
例外がスローされコード:
public class MainPreferenceActivity extends PreferenceActivity implements OnSharedPreferenceChangeListener {
//Google Market URL
private static final String RATE_APP_ANDROID_URL = "http://market.android.com/details?id=com.andrew.notifyme";
//Amazon Appstore URL
private static final String RATE_APP_AMAZON_URL = "http://www.amazon.com/gp/mas/dl/android?p=com.andrew.notifyme";
private static final String APP_ENABLED_KEY = "app_enabled";
private static final String CALENDAR_NOTIFICATIONS_ENABLED_KEY = "calendar_notifications_enabled";
private static final String LANDSCAPE_SCREEN_ENABLED_KEY = "landscape_screen_enabled";
private static final String CALENDAR_SELECTION_KEY = "calendar_selection";
private static final String CALENDAR_POLLING_FREQUENCY_KEY = "calendar_polling_frequency";
private static final int NOTIFICATION_TYPE_TEST = -1;
private boolean _debug = false;
private Context _context = null;
private boolean _debugCalendar = false;
private SharedPreferences _preferences = null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
_debug = Log.getDebug();
if (_debug) Log.v("MainPreferenceActivity.onCreate()");
_debugCalendar = Log.getDebugCalendar();
_context = MainPreferenceActivity.this;
_preferences = PreferenceManager.getDefaultSharedPreferences(_context);
_preferences.registerOnSharedPreferenceChangeListener(this);
//Don't rotate the Activity when the screen rotates based on the user preferences.
if(!_preferences.getBoolean(LANDSCAPE_SCREEN_ENABLED_KEY, false)){
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
addPreferencesFromResource(R.xml.preferences);
setupCustomPreferences();
runOnceAlarmManager();
setupAppDebugMode(_debug);
setupRateAppPreference();
setupImportPreferences();
runOnceEula();
}
これをエミュレータでデバッグすると、logcatは何を表していますか? –
私はpastebinからのスタックトレースを質問にコピーしました。 stack traceのような小さなものにはpastebinを使わないでください。それは大きな不便です。 – EboMike
このタグは必要ありませんか?xmlns:android = "http://schemas.android.com/apk/res/android" – ngesh