<Preferencecategory androID:title="Synchronization"> ... </Preferencecategory>
我正在尝试使用xml属性更改背景:
androID:WidgetLayout="@style/Preferencecategory"
我的styles.xml中的代码如下所示:
<resources><style name="Preferencecategory"> <item name="androID:background">@color/my_blue</item></style></resources>
但它不能正常工作.我有致命的例外:
08-13 01:43:09.111: WARN/dalvikvm(1329): threadID=1: thread exiting with uncaught exception (group=0x40015560)08-13 01:43:09.141: ERROR/AndroIDRuntime(1329): FATAL EXCEPTION: main08-13 01:43:09.141: ERROR/AndroIDRuntime(1329): androID.content.res.Resources$NotFoundException: Resource ID #0x7f09000608-13 01:43:09.141: ERROR/AndroIDRuntime(1329): at androID.content.res.Resources.getValue(Resources.java:892)08-13 01:43:09.141: ERROR/AndroIDRuntime(1329): at androID.content.res.Resources.loadXmlResourceParser(Resources.java:1869)08-13 01:43:09.141: ERROR/AndroIDRuntime(1329): at androID.content.res.Resources.getLayout(Resources.java:731)08-13 01:43:09.141: ERROR/AndroIDRuntime(1329): at androID.vIEw.LayoutInflater.inflate(LayoutInflater.java:318)08-13 01:43:09.141: ERROR/AndroIDRuntime(1329): at androID.vIEw.LayoutInflater.inflate(LayoutInflater.java:276)08-13 01:43:09.141: ERROR/AndroIDRuntime(1329): at androID.preference.Preference.onCreateVIEw(Preference.java:416)08-13 01:43:09.141: ERROR/AndroIDRuntime(1329): at androID.preference.Preference.getVIEw(Preference.java:389)08-13 01:43:09.141: ERROR/AndroIDRuntime(1329): at androID.preference.PreferenceGroupAdapter.getVIEw(PreferenceGroupAdapter.java:221)08-13 01:43:09.141: ERROR/AndroIDRuntime(1329): at androID.Widget.AbsListVIEw.obtainVIEw(AbsListVIEw.java:1418)08-13 01:43:09.141: ERROR/AndroIDRuntime(1329): at androID.Widget.ListVIEw.makeAndAddVIEw(ListVIEw.java:1745)08-13 01:43:09.141: ERROR/AndroIDRuntime(1329): at androID.Widget.ListVIEw.fillDown(ListVIEw.java:670)08-13 01:43:09.141: ERROR/AndroIDRuntime(1329): at androID.Widget.ListVIEw.fillFromtop(ListVIEw.java:727)08-13 01:43:09.141: ERROR/AndroIDRuntime(1329): at androID.Widget.ListVIEw.layoutChildren(ListVIEw.java:1598)08-13 01:43:09.141: ERROR/AndroIDRuntime(1329): at androID.Widget.AbsListVIEw.onLayout(AbsListVIEw.java:1248)08-13 01:43:09.141: ERROR/AndroIDRuntime(1329): at androID.vIEw.VIEw.layout(VIEw.java:7175)08-13 01:43:09.141: ERROR/AndroIDRuntime(1329): at androID.Widget.relativeLayout.onLayout(relativeLayout.java:912)08-13 01:43:09.141: ERROR/AndroIDRuntime(1329): at androID.vIEw.VIEw.layout(VIEw.java:7175)08-13 01:43:09.141: ERROR/AndroIDRuntime(1329): at androID.Widget.FrameLayout.onLayout(FrameLayout.java:338)08-13 01:43:09.141: ERROR/AndroIDRuntime(1329): at androID.vIEw.VIEw.layout(VIEw.java:7175)08-13 01:43:09.141: ERROR/AndroIDRuntime(1329): at androID.Widget.FrameLayout.onLayout(FrameLayout.java:338)08-13 01:43:09.141: ERROR/AndroIDRuntime(1329): at androID.vIEw.VIEw.layout(VIEw.java:7175)08-13 01:43:09.141: ERROR/AndroIDRuntime(1329): at androID.vIEw.VIEwRoot.performTraversals(VIEwRoot.java:1140)08-13 01:43:09.141: ERROR/AndroIDRuntime(1329): at androID.vIEw.VIEwRoot.handleMessage(VIEwRoot.java:1859)08-13 01:43:09.141: ERROR/AndroIDRuntime(1329): at androID.os.Handler.dispatchMessage(Handler.java:99)08-13 01:43:09.141: ERROR/AndroIDRuntime(1329): at androID.os.Looper.loop(Looper.java:123)08-13 01:43:09.141: ERROR/AndroIDRuntime(1329): at androID.app.ActivityThread.main(ActivityThread.java:3647)08-13 01:43:09.141: ERROR/AndroIDRuntime(1329): at java.lang.reflect.Method.invokeNative(Native Method)08-13 01:43:09.141: ERROR/AndroIDRuntime(1329): at java.lang.reflect.Method.invoke(Method.java:507)08-13 01:43:09.141: ERROR/AndroIDRuntime(1329): at com.androID.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)08-13 01:43:09.141: ERROR/AndroIDRuntime(1329): at com.androID.internal.os.ZygoteInit.main(ZygoteInit.java:597)08-13 01:43:09.141: ERROR/AndroIDRuntime(1329): at dalvik.system.NativeStart.main(Native Method)
当我将颜色形式@ color / my_blue更改为某些十六进制代码时,我有同样的致命异常.
我知道我可以在AndroIDManifest中使用我的首选项活动这个xml属性:
androID:theme="@style/Preferencestheme"
但它会改变我所有偏好活动的背景颜色.我可以通过哪种方式更改首选项部分的属性?
解决方法 我认为问题在于,当您期望包含视图的样式/主题/布局替换首选项中的当前视图时,您尝试传递仅具有指定背景颜色的样式/主题.androID:WidgetLayout文档中的示例说
a checkBox preference would specify a custom layout (consisting of
just the CheckBox) here
另一种选择是通过覆盖Preferencecategory的onBindVIEw()来尝试在代码中执行此 *** 作.
是的,更改AndroIDManfIEst.xml中的主题应根据您指定的位置更改整个Application或Activity的背景颜色(在本例中).
@H_403_2@ 总结以上是内存溢出为你收集整理的android – 更改首选项类别标签颜色背景全部内容,希望文章能够帮你解决android – 更改首选项类别标签颜色背景所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)