これは、SearchSetttingActivity で使用される設定ヘッダー ファイルです。
<header android:fragment="com.android.quicksearchbox.preferences.SearchableItemsFragment" android:title="@string/search_sources" /> <header android:fragment="com.android.quicksearchbox.preferences.DeviceSearchFragment" android:title="@string/device_settings_category_title" /> <header android:fragment="com.android.quicksearchbox.preferences.SearchEngineFragment" android:title="@string/pref_content_search_engine" />
3番目のフラグメントは私が追加したものです。
これは、以下の私の SearchEngineFragment ソースです。
package com.android.quicksearchbox.preferences; import com.android.quicksearchbox.R; public class SearchEngineFragment extends SettingsFragmentBase { public SearchEngineFragment() { } @Override protected int getPreferencesResourceId() { return R.xml.search_engine_preferences; }
}
毎回 PreferenceActivity から 3 番目の項目をタッチすると、毎回クラッシュしました。クラッシュ ログは次のとおりです。
FATAL EXCEPTION: main
03-06 23:10:48.133 E/AndroidRuntime( 803): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.quicksearchbox/com.android.quicksearchbox.preferences.SearchSettingsActivity}: android.app.Fragment$InstantiationException: Unable to instantiate fragment com.android.quicksearchbox.preferences.SearchEngineFragment: make sure class name exists, is public, and has an empty constructor that is public
03-06 23:10:48.133 E/AndroidRuntime( 803): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
03-06 23:10:48.133 E/AndroidRuntime( 803): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
03-06 23:10:48.133 E/AndroidRuntime( 803): at android.app.ActivityThread.access$600(ActivityThread.java:123)
03-06 23:10:48.133 E/AndroidRuntime( 803): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
03-06 23:10:48.133 E/AndroidRuntime( 803): at android.os.Handler.dispatchMessage(Handler.java:99)
03-06 23:10:48.133 E/AndroidRuntime( 803): at android.os.Looper.loop(Looper.java:137)
03-06 23:10:48.133 E/AndroidRuntime( 803): at android.app.ActivityThread.main(ActivityThread.java:4424)
03-06 23:10:48.133 E/AndroidRuntime( 803): at java.lang.reflect.Method.invokeNative(Native Method)
03-06 23:10:48.133 E/AndroidRuntime( 803): at java.lang.reflect.Method.invoke(Method.java:511)
03-06 23:10:48.133 E/AndroidRuntime( 803): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
03-06 23:10:48.133 E/AndroidRuntime( 803): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
03-06 23:10:48.133 E/AndroidRuntime( 803): at dalvik.system.NativeStart.main(Native Method)
03-06 23:10:48.133 E/AndroidRuntime( 803): Caused by: android.app.Fragment$InstantiationException: Unable to instantiate fragment com.android.quicksearchbox.preferences.SearchEngineFragment: make sure class name exists, is public, and has an empty constructor that is public
03-06 23:10:48.133 E/AndroidRuntime( 803): at android.app.Fragment.instantiate(Fragment.java:581)
03-06 23:10:48.133 E/AndroidRuntime( 803): at android.preference.PreferenceActivity.switchToHeaderInner(PreferenceActivity.java:1117)
03-06 23:10:48.133 E/AndroidRuntime( 803): at android.preference.PreferenceActivity.switchToHeader(PreferenceActivity.java:1133)
03-06 23:10:48.133 E/AndroidRuntime( 803): at android.preference.PreferenceActivity.onCreate(PreferenceActivity.java:532)
03-06 23:10:48.133 E/AndroidRuntime( 803): at android.app.Activity.performCreate(Activity.java:4465)
03-06 23:10:48.133 E/AndroidRuntime( 803): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
03-06 23:10:48.133 E/AndroidRuntime( 803): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
03-06 23:10:48.133 E/AndroidRuntime( 803): ... 11 more
03-06 23:10:48.133 E/AndroidRuntime( 803): Caused by: java.lang.ClassNotFoundException: com.android.quicksearchbox.preferences.SearchEngineFragment
03-06 23:10:48.133 E/AndroidRuntime( 803): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
03-06 23:10:48.133 E/AndroidRuntime( 803): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
03-06 23:10:48.133 E/AndroidRuntime( 803): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
03-06 23:10:48.133 E/AndroidRuntime( 803): at android.app.Fragment.instantiate(Fragment.java:571)
03-06 23:10:48.133 E/AndroidRuntime( 803): ... 17 more
助けてください、ありがとう!