java.lang.UnsupportedOperationException: Can't convert to integer: type=0x3

前几天在编写一个自定义控件的时候,出现了这个这个异常:

Caused by: java.lang.UnsupportedOperationException: Can‘t convert to integer: type=0x3

然后定位到代码中的时候,发现是自定义控件中引用资源的时候报的错误,代码片段如下:

int iconId = mTypedArray.getInteger(R.styleable.TitleBar_icon, 0);
iconIv.setImageResource(iconId);

在执行mTypedArray.getInteger()方法的时候出现报错,根据报错信息字面意思是因为获取的资源id无法转换为integer类型才报错的,于是我将getInteger()改为了getResourceId()方法,这回程序就运行正常了。

int iconId = mTypedArray.getResourceId(R.styleable.TitleBar_icon, 0);
iconIv.setImageResource(iconId);

至于深层次的原因,我现在还不清楚,期待有人可以给我解答,谢谢~

java.lang.UnsupportedOperationException: Can't convert to integer: type=0x3

时间: 2024-08-08 19:07:36

java.lang.UnsupportedOperationException: Can't convert to integer: type=0x3的相关文章

java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x1

遇到这个bug: 末尾是解决方法.  E/AndroidRuntime: FATAL EXCEPTION: main                                                                         Process: com.XX.XX.XX, PID: 7055                                                                         java.lang.Runt

java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x12

最近使用Android Studio开发一个新项目,刚做完几个界面,跑在android 5.0上面很正常,因为都是挺简单的布局,本以为应该不存在兼容性问题(Flag啊). 偶然用了一个4.x的实机测试,发现杯具了,直接报错退出了,发现log里面打出这么一句: java.lang.UnsupportedOperationException: Can't convert to color: type=0x2 难以理解啊,没办法一步一步调试吧. 顺便说一下调试要注意的问题,如果compileSdkVe

Hbase delete遇到的常见异常: Exception in thread "main" java.lang.UnsupportedOperationException

hbase 执行批量删除时出现错误: Exception in thread "main" java.lang.UnsupportedOperationException at java.util.AbstractList.remove(AbstractList.java:161) at org.apache.hadoop.hbase.client.HTable.delete(HTable.java:852) 这种异常其实很常见,remove操作不支持,为什么会出现不支持的情况呢?检查

Android -- Canvas java.lang.UnsupportedOperationException

干货 java.lang.UnsupportedOperationException at android.view.GLES20Canvas.clipPath(GLES20Canvas.java:287) at br.com.iba.view.PageCurlView.drawCurl(PageCurlView.java:284) at br.com.iba.view.PageCurlView.onDraw(PageCurlView.java:353) at android.view.View

java.lang.UnsupportedOperationException

在使用Arrays.asList()后调用add,remove这些method时出现java.lang.UnsupportedOperationException异常.这是由于Arrays.asList() 返回java.util.Arrays$ArrayList, 而不是ArrayList.Arrays$ArrayList和ArrayList都是继承AbstractList,remove,add等method在AbstractList中是默认throw UnsupportedOperation

mybatis java.lang.UnsupportedOperationException

mybatis 的mapper配置的select查询语句,报java.lang.UnsupportedOperationException 内容如下: org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: java.lang.UnsupportedOpe

java.lang.UnsupportedOperationException:This parser does not support specification "null" version "null"

java.lang.UnsupportedOperationException: This parser does not support specification "null" version "null" at javax.xml.parsers.SAXParserFactory.setXIncludeAware(SAXParserFactory.java:448) at org.apache.commons.digester.Digester.getFact

解决错误java.lang.UnsupportedOperationException

遇到错误 Error:Execution failed for task ':app:transformClassesWithDexForDebug'. > com.Android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: Java.util.concurrent.ExecutionException: java.lang.UnsupportedOperatio

java.lang.UnsupportedOperationException: Not supported by BasicDataSource

场景: SpringMVC+Hibernate+Maven 问题: 在src/main/resources 目录中添加hibernate.properties文件, 则如果存在这句hibernate.hbm2ddl.auto=update 启动tomcat就报如下异常, 去掉启动不报错,访问servlet的时候报错,去掉文件中所有属性,访问也不报错hibernate.properties 文件内容:hibernate.connection.driver_class=com.mysql.jdbc.