Android 在array.xml中使用color.xml引用
我正在尝试调试屏幕,它显示openCV项目中验证过程的各个阶段,这些是指检测到的blob (切入正题) array.xml引用Android 在array.xml中使用color.xml引用,android,android-studio,Android,Android Studio,我正在尝试调试屏幕,它显示openCV项目中验证过程的各个阶段,这些是指检测到的blob (切入正题) array.xml引用 <item>"@color/debug_IsCircular"</item> 我用颜色表示上述内容,以便(在显示器上)看到正在发生的事情 要分离调试,我需要在中设置详细度 preferences.xml <ListPreference android:dependency="@string/settin
<item>"@color/debug_IsCircular"</item>
我用颜色表示上述内容,以便(在显示器上)看到正在发生的事情
要分离调试,我需要在中设置详细度
preferences.xml
<ListPreference
android:dependency="@string/settings_displayKey"
android:dialogTitle="@string/settings_debugVerbosityTitle"
android:title="@string/settings_debugVerbosityTitle"
android:summary="@string/settings_debugVerbositySummary"
android:key="@string/settings_debugVerbosityKey"
android:defaultValue="0"
android:entries="@array/debugVerbosity"
android:entryValues="@array/debugVerbosityValue"
/>
这可以硬编码,但我想使用引用,因为它们应该可以工作。我遗漏了什么?您会发布堆栈跟踪吗?
NumberFormatException:Invalid int:“@color/debug\u IsCircular”
-很明显,字符串“@color/debug\u IsCircular”
无法解析为整数,这显然是您在RetreiveSettings()
中尝试的。展示这些代码也会很有帮助。理论上,您应该能够使@color/debug\u IsCircular
(不带引号)正常工作,但您可能必须处理作为引用的值,而不是描述颜色值的实际整数。很抱歉,我现在在那里添加了不正确的LogCat-correct。FC错误仍然存在。
debug_TooBigTooSmall > Show All
debug_WrongRatio > Show Most
debug_NotSquare > Show Some
debug_NotCircular > Show Minimal
debug_IsCircular > Show Only Sucessful
<ListPreference
android:dependency="@string/settings_displayKey"
android:dialogTitle="@string/settings_debugVerbosityTitle"
android:title="@string/settings_debugVerbosityTitle"
android:summary="@string/settings_debugVerbositySummary"
android:key="@string/settings_debugVerbosityKey"
android:defaultValue="0"
android:entries="@array/debugVerbosity"
android:entryValues="@array/debugVerbosityValue"
/>
<string-array name="debugVerbosity">
<item>All</item>
<item>Most</item>
<item>Some</item>
<item>Minimal</item>
</string-array>
<string-array name="debugVerbosityValue">
<item>"@color/debug_IsCircular"</item>
<item>2</item>
<item>1</item>
<item>0</item>
</string-array>
<item>"@color/debug_IsCircular"</item>
<item>@color/debug_IsCircular</item>
07-06 14:57:53.920 25717-25717/com.anthonykeane.speedsignfinder E/AndroidRuntime: FATAL EXCEPTION: main
java.lang.NullPointerException
at android.preference.ListPreference.onDialogClosed(ListPreference.java:264)
at android.preference.DialogPreference.onDismiss(DialogPreference.java:390)
at android.app.Dialog$ListenersHandler.handleMessage(Dialog.java:1233)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4898)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1006)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)
at dalvik.system.NativeStart.main(Native Method)