关于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 ...
随机推荐
- 【PHP升级】CentOS6.3编译安装 PHP5.4.38
先前安装的PHP5.3.28(参考:CentOS6.3编译安装Nginx1.4.7 + MySQL5.5.25a + PHP5.3.28),现在准备升级PHP到5.4.38,有如下几个地方需要重新编译 ...
- Shell入门教程:算术运算
Bash的算术运算有以下几种方法: 序号 名称 语法 范例 1 算术扩展 $((算术式)) r=$((2+5*8)) 2 使用外部程序 expr 算术式 r=`expr 4 + 5` 3 使用 $[] ...
- 【Python网络爬虫一】爬虫原理和URL基本构成
1.爬虫定义 网络爬虫,即Web Spider,是一个很形象的名字.把互联网比喻成一个蜘蛛网,那么Spider就是在网上爬来爬去的蜘蛛.网络蜘蛛是通过网页的链接地址来寻找网页的.从网站某一个页面(通常 ...
- 利用Mongoose来结构化模式与验证
Mongoose是一个文档对象模型(ODM)库,为MongoDB Node.js原生驱动程序提供更多的功能. 把结构化的模式应用到一个MongoDB集合,提供了验证和类型转换的好处 Mongoose通 ...
- JMeter遇到的问题一:Error writing to server(转)
Java.io.IOException: Error writing to server异常:我测试500个并发时,系统没有问题:可当我把线程数加到800时,就出现错误了,在"查看结果树&q ...
- linux svn 搭建
原文:http://jingyan.baidu.com/article/3c343ff7039de20d37796306.html和http://blog.sina.com.cn/s/blog_670 ...
- string与wstring之间的转换
#include <string>std::string ws2s(const std::wstring& ws){ std::string curLocale = setl ...
- thinkphp 3.23语言包加载
模块home: 1.config 里添加 配置 //'配置项'=>'配置值' 'LANG_SWITCH_ON' => true, // 开启语言包功能 'LANG ...
- Android root + 修改host
1.使用KingRoot下载手机版,安装后进行Root处理. 2.下载 RE文件管理器,安装后,打开应用,进入etc,找到host, 勾选,菜单中选择 以文本方式编辑,修改好之后,按返回键 ,提示保存 ...
- 以前用SQL实现的机构职能树,再看看
DECLARE CNT NUMBER; TMP ); vtmp ); ltmp1 ); ltmp2 ); ltmp3 ); ltmp4 ); NTMP NUMBER; CURSOR CSR_TEST ...