自定义SurfaceView Unable to start activity ComponentInfo
来源:互联网 发布:外国电视台直播软件 编辑:程序博客网 时间:2024/04/23 20:03
自定义SurfaceView时,在xml中添加报错Unable to start activity ComponentInfo
<?xml version="1.0" encoding="utf-8" ?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:orientation="vertical" android:layout_height="fill_parent" > <LinearLayout android:id="@+id/operate" android:layout_height="wrap_content" android:layout_width="wrap_content" android:gravity="center_horizontal"> <Button android:id="@+id/btn_reset" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="重绘" android:layout_marginRight="20dp" /> <Button android:id="@+id/btn_clear" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="清除"/> </LinearLayout> <com.touch.view.MySurfaceView android:id="@+id/view" android:layout_width="fill_parent" android:layout_height="fill_parent" /></LinearLayout>
解决办法:
如果你的activity显示内容就只是一个surfaceview的话,那么你只重写public mysurfaceview(Context context)就可以,然后在activity的oncreate方法中使用类似于下面的代码加载:setContentView(new MySurfaceView(this));
如果你的SurfaceView是放在一个xml布局文件中比如main.xml中,那么你的SurfaceView中只需要重写public mysurfaceview(Context context, AttributeSet attrs),加载时就要这样:setContentView(R.layout.main);
重写一个构成函数
- 自定义SurfaceView Unable to start activity ComponentInfo
- Unable to start activity ComponentInfo
- Unable to start activity ComponentInfo
- Unable to start activity ComponentInfo
- Unable to start activity ComponentInfo
- Unable to start activity ComponentInfo 解决方法
- Unable to start activity ComponentInfo 解决方法
- Unable to start activity ComponentInfo 解决方法
- RuntimeException:Unable to start activity ComponentInfo
- Unable to start activity ComponentInfo 解决方法
- Unable to start activity ComponentInfo 解决方法
- 出现Unable to start activity ComponentInfo 解决办法
- 关于Unable to start activity ComponentInfo异常
- Unable to start activity ComponentInfo 解决方法
- Unable to start activity ComponentInfo 解决方法
- Unable to start activity ComponentInfo 解决方法
- xml用到surfaceview控件 遇到unable to start activity componentInfo类问题
- Android中的"Unable to start activity ComponentInfo"或者"Unable to instantiate activity ComponentInfo"的错误
- delphi BCC校验
- 阻抗匹配基础
- Android获取屏幕高度、状态栏高度、标题栏高度
- 金额小写转大写的函数(连续使用很久了)
- 游戏中%的应用
- 自定义SurfaceView Unable to start activity ComponentInfo
- 二分查找的递归与非递归实现
- 【转载】R6034错误,C Runtime Error
- java集合框架Set
- 横竖屏切换时候Activity的生命周期
- java之反射
- hdu 1509 Windows Message Queue 优先队列
- linux C函数之stat函数
- 横竖屏切换时候Activity的生命周期