PreferenceActivity第二次启动app时关闭

时间:2012-03-03 17:07:40

标签: android classnotfoundexception preferenceactivity

这是我的.java代码

   public class MainHelp extends PreferenceActivity {

        @Override
        public void onCreate(Bundle savedInstanceState){
            super.onCreate(savedInstanceState);
                addPreferencesFromResource(R.xml.help_main);
             }
       }

这是布局

<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >

    <Preference 
        android:title="Commands Documentation"
        android:key="@string/commands"/>

     <Preference
         android:title = "How To Use"
         android:key="@string/howToUse"/>
     <Preference 
         android:title="Write Us"
         android:key="@string/writeUs"/> 
     <Preference 
        android:title="About"
        android:key="@string/aboutSuppApp"/> 
</PreferenceScreen>

当我运行该程序时,上面的代码运行完美....但是,当我点击主页按钮并尝试转到此活动时,我收到错误说

E/AndroidRuntime(  495): Uncaught handler: thread main exiting due to uncaught exception
E/AndroidRuntime(  495): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.suppapp/com.suppapp.help.MainHelp}: android.view.InflateException: Binary XML file line #10: Error inflating class prferences
    E/AndroidRuntime(  495):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
    E/AndroidRuntime(  495):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
    E/AndroidRuntime(  495):    at android.app.ActivityThread.access$2200(ActivityThread.java:119)
    E/AndroidRuntime(  495):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
    E/AndroidRuntime(  495):    at android.os.Handler.dispatchMessage(Handler.java:99)
    E/AndroidRuntime(  495):    at android.os.Looper.loop(Looper.java:123)
    E/AndroidRuntime(  495):    at android.app.ActivityThread.main(ActivityThread.java:4363)
    E/AndroidRuntime(  495):    at java.lang.reflect.Method.invokeNative(Native Method)
    E/AndroidRuntime(  495):    at java.lang.reflect.Method.invoke(Method.java:521)
    E/AndroidRuntime(  495):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
    E/AndroidRuntime(  495):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
    E/AndroidRuntime(  495):    at dalvik.system.NativeStart.main(Native Method)
    E/AndroidRuntime(  495): Caused by: android.view.InflateException: Binary XML file line #10: Error inflating class prferences
    E/AndroidRuntime(  495):    at android.preference.GenericInflater.createItemFromTag(GenericInflater.java:441)
    E/AndroidRuntime(  495):    at android.preference.GenericInflater.rInflate(GenericInflater.java:481)
    E/AndroidRuntime(  495):    at android.preference.GenericInflater.inflate(GenericInflater.java:326)
    E/AndroidRuntime(  495):    at android.preference.GenericInflater.inflate(GenericInflater.java:263)
    E/AndroidRuntime(  495):    at android.preference.PreferenceManager.inflateFromResource(PreferenceManager.java:254)
    E/AndroidRuntime(  495):    at android.preference.PreferenceActivity.addPreferencesFromResource(PreferenceActivity.java:253)
    E/AndroidRuntime(  495):    at com.suppapp.help.MainHelp.onCreate(MainHelp.java:19)
    E/AndroidRuntime(  495):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
    E/AndroidRuntime(  495):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
    E/AndroidRuntime(  495):    ... 11 more
    E/AndroidRuntime(  495): Caused by: java.lang.ClassNotFoundException: android.preference.prferences in loader dalvik.system.PathClassLoader@44c06600
    E/AndroidRuntime(  495):    at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
    E/AndroidRuntime(  495):    at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
    E/AndroidRuntime(  495):    at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
    E/AndroidRuntime(  495):    at android.preference.GenericInflater.createItem(GenericInflater.java:375)
    E/AndroidRuntime(  495):    at android.preference.GenericInflater.onCreateItem(GenericInflater.java:417)
    E/AndroidRuntime(  495):    at android.preference.GenericInflater.createItemFromTag(GenericInflater.java:428)
    E/AndroidRuntime(  495):    ... 19 more 

我尝试将我的活动与其他.xml文件关联,但又一次收到同样的错误!!甚至引起:android.view.InflateException:二进制XML文件行#10:错误膨胀类prferences显示其他.xml文件的相同行号(#10)

1 个答案:

答案 0 :(得分:1)

我更改了version code(内部manifest文件)并重新安装了应用...现在工作正常。