Android自定义视图属性 - 不允许使用“颜色”作为属性名称(Android custom view attributes - 'color' as attribute name disallowed)
我做了一个简单的自定义视图,一个“ColorSwatch”。 它是圆形的,显示指定的颜色,如果该颜色具有透明度,则在检查器图案上绘制颜色。 视图工作正常。
我的问题是,当我为swatch定义自定义属性时(在
values/attrs_color_swatch_view.xml
),我无法指定名为“color”的属性。 编译器抱怨颜色已经定义,并指向我的colors.xml文件。 作为一种解决方法,我调用了参数swatchColor
,但我更喜欢它只是color
。文件:
values/attrs_color_swatch_view.xml
<resources> <declare-styleable name="ColorSwatchView"> <attr name="swatchColor" format="color"/><!-- would prefer to simply be 'color', not 'swatchColor' --> <attr name="selectionThickness" format="dimension"/> <attr name="isSelected" format="boolean"/> <attr name="selectionColor" format="color"/> <attr name="alphaCheckerSize" format="dimension" /> </declare-styleable> </resources>
有没有办法使用属性名称
color
? 或者它是保留的关键字? 有没有办法以某种方式将它命名为我的视图?I've made a simple custom view, a "ColorSwatch". It's circular, shows the assigned color and if that color has transparency, the color is drawn atop a checker pattern. The view works fine.
My problem is that when I define the custom attributes for the swatch (in
values/attrs_color_swatch_view.xml
), I can't specify an attribute named "color". The compiler complains that color is already defined, and points me to my colors.xml file. As a workaround, I called the parameterswatchColor
, but I'd prefer it to simply becolor
.The file:
values/attrs_color_swatch_view.xml
<resources> <declare-styleable name="ColorSwatchView"> <attr name="swatchColor" format="color"/><!-- would prefer to simply be 'color', not 'swatchColor' --> <attr name="selectionThickness" format="dimension"/> <attr name="isSelected" format="boolean"/> <attr name="selectionColor" format="color"/> <attr name="alphaCheckerSize" format="dimension" /> </declare-styleable> </resources>
Is there a way to use the attribute name
color
? Or is it a reserved keyword? Is there a way to namespace it somehow to my view?
原文:https://stackoverflow.com/questions/33699561
最满意答案
对于faultHandling,请使用选项/ useSerializerForFaults以避免重复
The above problem has been removed when i pass /importXmlTypes parameter to the svcutil.exe.
相关问答
更多-
对于faultHandling,请使用选项/ useSerializerForFaults以避免重复 The above problem has been removed when i pass /importXmlTypes parameter to the svcutil.exe.
-
使用SvcUtil.exe / reference引用文件夹中的所有dll(referencing all dlls in a folder with SvcUtil.exe /reference)[2022-04-10]
你可以使用PowerShell来实现这一点: $endpoint = 'http://endpoint.svc?wsdl' $namespace = 'MyNamespace.Other' $generatedClassPath = 'C:...MyClass.cs' $librairiesDirectory = 'C:path-to-dlls' $svcUtilArgs = @( "/t:code" "$endpoint" "/n:`"*,$namespa ... -
据我所知,XSD.exe有一些限制; 例如当类中有Dictionary<,>时,XSD.exe不能生成适当的XSD; 因为Dictionary没有实现IXmlSerializable 。 As far as I know, there are some limitations with XSD.exe; for instance when there is a Dictionary<,> in the class, XSD.exe can not generate a proper XSD; as Dict ...
-
您应该在svcutil.exe之后关闭引号,而不是在行尾 - 命令提示符在您的行中找不到具有该名称的程序。 "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\SvcUtil.exe" /language:cs /out:generatedProxy.cs /config:app.config http://localhost:8000/Service You should close the quotes after svcu ...
-
我的问题是: 1)分发包中是否需要此文件/模式? (我想是的。) 2)是否符合标准? 3)是否存在任何互操作性问题? 一些利益相关者在Java和Delphi平台上。 4)为什么没有为ASMX服务生成类似的模式定义? 我的答案是: 1)是的,这是必要的 - 通常,WCF不生成不必要的东西.... 2)是的,它100%符合所有WS- *和XML Schema标准。 3)只有当等式的另一边不符合文件标准时...... 4)只有微软的设计师才能回答......我不知道 - 坦白说我不关心,因为ASMX是传统技术 M ...
-
DataContract格式仅支持XML模式定义的子集 。 所以它取决于服务元数据: svcutil (实际上是svcutil使用的System.ServiceModel.Description.WsdlImporter )默认尝试生成DataContracts。 如果遇到无法表示为DataContract的模式,它会生成MessageContract作为回退。 The DataContract format supports only a subset of XML Schema Definition. ...
-
有没有办法强制svcutil.exe忽略SSL证书问题?(Is there a way to force svcutil.exe to ignore SSL certificate issues?)[2022-04-10]
您可以先尝试浏览https站点,忽略证书不受信任的警告,然后单击证书并安装它。 这应该会导致您正在使用的机器信任证书。 然后尝试再次运行svcutil。 You could try browsing to the https site first, ignore the warning that the certificate is not trusted, then click on the certificate and install it. This should result in the mac ... -
SVCUTIL.EXE:任何分离我的Commons.xsd类的方法?(SVCUTIL.EXE: Any way to separate my Commons.xsd classes? (C#))[2021-10-03]
svcutil有一个/ namespace参数,允许您将wsdl名称空间映射到给定的代码名称空间。 你可以多次提供这个参数,但它没有很好的文档记录,所以你可能需要玩它很多...你可以指定一个通配符,但我不确定你是否可以挑出一个命名空间和通配符其余的部分。 我不确定这一点,但我认为如果你同时做两个wsdl,我认为它们将组合成一个.cs文件......也许它足够聪明,不会在那时复制类。 例如。 svcutil.exe "User.wsdl" "Customer.wsdl" "Commons.xsd" /n: ... -
好的,所以我已经过了这个错误。 (我现在得到更多,但那些是另一个问题)。 我在VS2010中打开了ws-addr.xsd文件并查看了警告列表。 一说: 警告105 XML编辑器尝试将此DTD转换为XSD,以便在您键入时提供验证和智能感知,但无法创建有效的XSD架构。 也许这个DTD使用的结构不会映射到XSD。 您可以使用“创建架构”命令获取有关该问题的更多信息。 D:\ Documents \ DEV \ SARPilot \ Docs \ eoschema \ schema \ ws-addressing ...
-
Svcutil.exe MSBuild任务(Svcutil.exe MSBuild Task)[2023-05-17]
您始终可以使用Exec任务并运行您想要的任何内容。 After searching extensively, there does not appear to be a task either included or available to do this.