关于java.lang.NoSuchMethodError: android.widget.RelativeLayout.setBackground的解决办法
今天用一个安卓4.0.4版本的手机测试手上的项目,发现logcat弹出这样一个提示“java.lang.NoSuchMethodError: android.widget.RelativeLayout.setBackground”,然后这个页面因为没有做异常捕获处理,所以直接导致系统崩溃了。检查后发现里面设置背景用的是setBackground()方法,而该方法是API16才开始有的。遇到这样的情况,将这个方法更改为setBackgroundDrawable()就可以了。
关于java.lang.NoSuchMethodError: android.widget.RelativeLayout.setBackground的解决办法的更多相关文章
- 【bug】java.lang.NoSuchMethodError: android.widget.TextView.setBackground
安卓的背景色设置需要根据SDK的版本来分情况考虑: if (Build.VERSION.SDK_INT >= 16) { textView.setBackground(null); } else ...
- java.lang.ClassCastException: android.widget.RelativeLayout cannot be cast to android.widget.TextView
最近在学习drawerLayout时,遇到这个bug.如下示: java.lang.ClassCastException: android.widget.RelativeLayout cannot b ...
- java.lang.ClassCastException: android.widget.RelativeLayout$LayoutParams cannot be cast to android.widget.AbsListView$LayoutParams
java.lang.ClassCastException: android.widget.RelativeLayout$LayoutParams cannot be cast to android.w ...
- java.lang.ClassCastException android.widget.RelativeLayout LayoutParams 异常
1.在xml布局文件如下所示: <RelativeLayout android:layout_width="match_parent" android:layout_heig ...
- Exception: java.lang.ClassCastException: android.widget.RelativeLayout$LayoutParams
RelativeLayout title_bg = (RelativeLayout)FTU_Bluetooth.this.findViewById(R.id.titlebar); LinearLayo ...
- java.lang.NoSuchMethodError: android.view.View.setBackground
int sdk = android.os.Build.VERSION.SDK_INT; if(sdk < android.os.Build.VERSION_CODES.JELLY_BEAN) { ...
- java.lang.NoSuchMethodError:android.content.Context.getDrawable
今天在开发的时候,这个代码在源码中是可以看到的,但是在android 4.3手机上面会报错,具体错误信息和代码如下: setBackgroundDrawable(context.getDrawable ...
- 调用android的getColor()方法出现 java.lang.NoSuchMethodError: android.content.res.Resources.getColor
1.java.lang.NoSuchMethodError: android.content.res.Resources.getDrawable/getColor或者 java.lang.NoSuch ...
- java.lang.ClassCastException: android.widget.TextView cannot be cast to android.widget.EditText
Caused by: Java.lang.ClassCastException: Android.widget.TextView cannot be cast to android.widget.Ed ...
随机推荐
- struts2 用if标签判断字符串包含
String testStr = "用来判断是否包含的字符串"; <s:property value="testStr"/> <s:if te ...
- 多种JSON格式及遍历方式
/*数组*/ var arr = [["name", "value"], ["name1", "value1"]]; v ...
- sql 创建表、删除表 增加字段 删除字段操作
下面是Sql Server 和 Access 操作数据库结构的常用Sql,希望对你有所帮助. 新建表:create table [表名]([自动编号字段] int IDENTITY (1,1) PRI ...
- jquery之toggleClass应用
今天记载一下常用的html + css + jquery效果应用 1.html内容 <div class="selBtn screen_btn"> <a id=& ...
- linux 命令笔记
linux 命令 创建目录 mkdir XX 列出目录 ls 进入目录 cd .. 进入上层目录 cd xx 进入xx目录 cd ~ 进入用户主目录 删除目录 rm -fr XX 清空目录,谨慎使用 ...
- 创建GitHub博客
1. 创建GitHub账号 GitHub技术博客首先需要GitHub账户,请在官网按照步骤自行注册账号. 2. 创建博客仓库 使用注册的账户登录,然后点击创建仓库,输入项目信息如下所示,注意项目名称规 ...
- eclipse配置jdk的src.zip源代码步骤
MyEclipse配置JDK的源代码的src.zip包很简单.只需要简单的几个步骤. 1.点 “window”-> “Preferences” -> “Java” -> “Insta ...
- layer使用方法
type - 基本层类型 类型:Number,默认:0 layer提供了5种层类型.可传入的值有:0(信息框,默认)1(页面层)2(iframe层)3(加载层)4(tips层). 若你采用layer. ...
- unrecognized selector sent to instance
今天长一见识(特此感谢小星星老湿-坏笑),凡是遇到“unrecognized selector sent to instance *******”的都是******方法没有,比如这种的错误: 可以尝试 ...
- jetty 内嵌服务
pom.xml <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncodin ...