我是android开发的新手。我正在关注他们的教程:android development
现在当我做
int defaultValue = getResources().getInteger(R.string.saved_high_score_default);
但是当我使用时出现错误:
int defaultValue = (int)R.string.saved_high_score_default;
它工作得很好。
这是我得到的错误:
08-25 07:38:13.228: E/AndroidRuntime(3436): FATAL EXCEPTION: main
08-25 07:38:13.228: E/AndroidRuntime(3436): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.android.fragments/com.example.android.fragments.MainActivity}: android.content.res.Resources$NotFoundException: Resource ID #0x7f040003 type #0x3 is not valid
08-25 07:38:13.228: E/AndroidRuntime(3436): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2110)
08-25 07:38:13.228: E/AndroidRuntime(3436): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2135)
08-25 07:38:13.228: E/AndroidRuntime(3436): at android.app.ActivityThread.access$700(ActivityThread.java:143)
08-25 07:38:13.228: E/AndroidRuntime(3436): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1241)
08-25 07:38:13.228: E/AndroidRuntime(3436): at android.os.Handler.dispatchMessage(Handler.java:99)
08-25 07:38:13.228: E/AndroidRuntime(3436): at android.os.Looper.loop(Looper.java:137)
08-25 07:38:13.228: E/AndroidRuntime(3436): at android.app.ActivityThread.main(ActivityThread.java:4953)
08-25 07:38:13.228: E/AndroidRuntime(3436): at java.lang.reflect.Method.invokeNative(Native Method)
08-25 07:38:13.228: E/AndroidRuntime(3436): at java.lang.reflect.Method.invoke(Method.java:511)
08-25 07:38:13.228: E/AndroidRuntime(3436): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1004)
08-25 07:38:13.228: E/AndroidRuntime(3436): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:771)
08-25 07:38:13.228: E/AndroidRuntime(3436): at dalvik.system.NativeStart.main(Native Method)
08-25 07:38:13.228: E/AndroidRuntime(3436): Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f040003 type #0x3 is not valid
08-25 07:38:13.228: E/AndroidRuntime(3436): at android.content.res.Resources.getInteger(Resources.java:838)
08-25 07:38:13.228: E/AndroidRuntime(3436): at com.example.android.fragments.HeadlinesFragment.onStart(HeadlinesFragment.java:60)
08-25 07:38:13.228: E/AndroidRuntime(3436): at android.support.v4.app.Fragment.performStart(Fragment.java:1332)
08-25 07:38:13.228: E/AndroidRuntime(3436): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:906)
08-25 07:38:13.228: E/AndroidRuntime(3436): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1080)
08-25 07:38:13.228: E/AndroidRuntime(3436): at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1062)
08-25 07:38:13.228: E/AndroidRuntime(3436): at android.support.v4.app.FragmentManagerImpl.dispatchStart(FragmentManager.java:1815)
08-25 07:38:13.228: E/AndroidRuntime(3436): at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:518)
08-25 07:38:13.228: E/AndroidRuntime(3436): at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1178)
08-25 07:38:13.228: E/AndroidRuntime(3436): at android.app.Activity.performStart(Activity.java:5170)
08-25 07:38:13.228: E/AndroidRuntime(3436): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2083)
08-25 07:38:13.228: E/AndroidRuntime(3436): ... 11 more
任何的想法 ?