草庐IT

declared_attr

全部标签

android - 错误 : "Error parsing XML: XML or text declaration not at start of entity"

我正在制作一个数独Android应用程序,我在main.xml下收到以下错误:“错误:解析XML时出错:XML或文本声明不在实体开头”任何帮助将不胜感激。这是我的代码。我在错误旁边放了“✗”`✗` 最佳答案 可能有两种情况-案例1-如果您在第一条语句之前有一个空格。案例2-如果您不小心将相同的命名空间语句放置了两次,即-?xmlversion="1.0"encoding="utf-8"?我做了一次,在更正后遇到了同样的错误,我的代码运行良好。希望这会有所帮助 关于android-错误:"

Androidx 模块,android :attr/ttcIndex & android:attr/fontVariationSettings not found

我正在将所有支持/appcompat库迁移到androidx。在所有更新之后,由于此错误,我无法构建我的项目:app:processDebugManifestUP-TO-DATEAGPBI:{"kind":"error","text":"error:resourceandroid:attr/fontVariationSettingsnotfound.","sources":[{"file":"/Users/xxx/.gradle/caches/transforms-1/files-1.1/appcompat-v7-27.1.1.aar/7cae290a69b05f5ffc25283e2

android - 自定义 attr 获取颜色返回无效值

我有一个自定义View,我想在其中设置TextView的颜色。我有attrs.xml我在布局文件中设置了我在我的代码中设置了它TypedArraya=context.getTheme().obtainStyledAttributes(attrs,R.styleable.PropertyView,0,0);showTitle=a.getBoolean(R.styleable.PropertyView_showTitle,false);Stringtitle=a.getString(R.styleable.PropertyView_propertyTitle);floattextSize=

android - 访问在主题和 attrs.xml android 中定义的资源

我有一个场景,我想根据定义的主题设置Drawable。为了进一步解释这一点,这是我在代码中的内容:\res\values\attrs.xmlres\values\styles.xml@drawable/ic_homeAndroidManifest.xml正如您所注意到的,我正在定义一个自定义attrhomeIcon并在AppTheme中设置属性值。当我在布局XML中定义此属性并尝试访问它时,它工作顺利并在ImageView中呈现Drawableic_home。但我无法弄清楚如何以编程方式访问Drawable。我试图通过定义一个持有者LayerListDrawable来解决这个问题,这会

android - 如何在代码中获取 attr 引用?

我希望通过代码从属性中获取指向引用。在我的xml布局中,我可以像这样轻松获得引用的可绘制对象:android:background="?attr/listItemBackground"属性引用由我的主题设置。我正在寻找是否可以通过代码获取引用的可绘制对象。我可以通过创建样式attr并读取自定义View中的值来解决此问题,但在这种情况下,我想弄清楚这是否可能不做所有这些。我认为这是可能的,但我还没有找到获取该属性引用的方法。谢谢! 最佳答案 这就是你的做法://Createanarrayoftheattributeswewanttor

C++ "std::string has not been declared"错误

我一直在网站上寻找答案,但找不到任何对我有帮助的答案。当我尝试(如建议的那样)添加这些行时,我有一个使用字符串的代码:usingnamespacestd;usingstd::string;#include我尝试单独使用它们中的每一个,然后将它们一起尝试。最好的情况是所有字符串错误都消失了,但我在“使用std::string”这一行出现了另一个奇怪的错误,错误是:std::string尚未声明。有任何想法吗?谢谢大家。 最佳答案 把#include首先。避免usingheader中的语句,因为您可能会将各种东西带入许多编译单元。usi

c++ - 如何删除 VS 警告 C4091 : 'typedef ' : ignored on left of 'SPREADSHEET' when no variable is declared

此警告在我的代码中由同一个声明多次触发,内容如下://SpreadsheetstructuretypedefstructSPREADSHEET{intID;//IDofthespreadsheetUINTnLines;//NumberoflinesvoidCopyFrom(constSPREADSHEET*src){ID=src->ID;nLines=src->nLines;}};我不想只是关闭该警告,而是更改代码,以免出现警告!注意:我不想在这里声明任何变量(它是一个头文件),只定义结构'SPREADSHEET'应该包含的内容... 最佳答案

c++ - 在标准中,什么是 "derived-declarator-type"?

在C++(C++11)标准的不同地方,声明是根据derived-declarator-type-list来描述的。我正在研究右值引用,在这种情况下使用这个术语是至关重要的(第8.3.2节):InadeclarationTDwhereDhaseitheroftheforms    &attribute-specifier-seqoptD1    &&attribute-specifier-seqoptD1andthetypeoftheidentifierinthedeclarationTD1is“derived-declarator-type-listT,”thenthetypeofth

C++ 错误 : ‘string’ has not been declared

在我的头文件中,我得到了error:‘string’hasnotbeendeclared错误,但在文件顶部我有#include,那么我怎么会得到这个错误呢? 最佳答案 string位于std命名空间中,您必须使用std::string或通过using指令或using将其引入范围声明。 关于C++错误:‘string’hasnotbeendeclared,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/

c++ - 对依赖基类成员的非限定访问导致 "A declaration of [x] must be available"

代码://test3.cpp#includeusingnamespacestd;templatestructptr_stack_tp;templatestructptr_stack_tp:publicstack{~ptr_stack_tp(){while(!empty()){operatordelete(top());pop();}}};intmain(){}错误信息(gcc4.7.2):test3.cpp:Indestructor'ptr_stack_tp::~ptr_stack_tp()':test3.cpp:15:23:error:therearenoargumentsto'em