1.在xml布局文件如下所示: <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@android:color/darker_gray" android:paddingBottom="5dp" android:paddingTop="5dp&qu…
RelativeLayout title_bg = (RelativeLayout)FTU_Bluetooth.this.findViewById(R.id.titlebar); LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, 0x55); title_bg.setLayoutParams(params); 如果用RelativeLayout.LayoutPara…
java.lang.ClassCastException: android.widget.RelativeLayout$LayoutParams cannot be cast to android.widget.AbsListView$LayoutParams FrameLayout的父控件是一个LinearLayout控件,问题出在,LinearLayout为子控件分配空间的时候,获取FrameLayout的LayoutParams的必须为LinearLayout.LayoutParams,而…
最近在学习drawerLayout时,遇到这个bug.如下示: java.lang.ClassCastException: android.widget.RelativeLayout cannot be cast to android.widget.TextView 原因: 可能是没有在适配器参数内加入TextView的id. 解决方案: 将原来的适配器参数代码 mDrawerList.setAdapter(new ArrayAdapter<String>(this,R.layout.list…
最近,在android中用代码动态改变某种布局(组件)的高度时,会遇到如题所示的类转换异常.上网查了一下,如下所示: These supply parameters to the parent of this view specifying how it should be arranged. There are many subclasses of ViewGroup.LayoutParams, and these correspond to the different subclasses…
09-09 10:19:59.979: E/AndroidRuntime(2767): FATAL EXCEPTION: main09-09 10:19:59.979: E/AndroidRuntime(2767): java.lang.ClassCastException: android.view.ViewGroup$LayoutParams cannot be cast to android.widget.LinearLayout$LayoutParams09-09 10:19:59.97…
今天用一个安卓4.0.4版本的手机测试手上的项目,发现logcat弹出这样一个提示“java.lang.NoSuchMethodError: android.widget.RelativeLayout.setBackground”,然后这个页面因为没有做异常捕获处理,所以直接导致系统崩溃了.检查后发现里面设置背景用的是setBackground()方法,而该方法是API16才开始有的.遇到这样的情况,将这个方法更改为setBackgroundDrawable()就可以了.…
在调程序时总是出现异常关闭的现象,log显示: 03-26 07:58:09.528: E/AndroidRuntime(398): Caused by: java.lang.ClassCastException: android.widget.ImageButton XML中: JAVA文件中: 解决方法: 把两个控件类型改成一致的就可以了.…
Caused by: Java.lang.ClassCastException: Android.widget.TextView cannot be cast to android.widget.EditText 该种报错信息,检查代码确定无误后,若还是出现这种错误,则可通过以下这个办法进行解决: 点中该项目-->点击Project-->clean   清理下再重新运行该项目…
Caused by: Java.lang.ClassCastException: Android.widget.TextView cannot be cast to android.widget.EditText 该种报错信息,检查代码确定无误后,若还是出现这种错误,则可通过以下这个办法进行解决: 点中该项目-->点击Project-->clean   清理下再重新运行该项目,然后就解决了…