我写了最简单的继承View的类:代码如下public class MyView extends View
{ public MyView(Context context)
{
super(context);
}
public MyView(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
} protected void OnDraw(Canvas canvas)
{
super.onDraw(canvas);
}
}XML:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<com.main.sufaceview.MyView
android:id="@+id/myview"
android:layout_width="300dp"
android:layout_height="300dp"
android:background="@drawable/tt"/> </RelativeLayout>
结果一进入虚拟机就出现奔溃
这是什么情况,自定义的view应该是最简单的吧,没加别的代码都出错
{ public MyView(Context context)
{
super(context);
}
public MyView(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
} protected void OnDraw(Canvas canvas)
{
super.onDraw(canvas);
}
}XML:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<com.main.sufaceview.MyView
android:id="@+id/myview"
android:layout_width="300dp"
android:layout_height="300dp"
android:background="@drawable/tt"/> </RelativeLayout>
结果一进入虚拟机就出现奔溃
这是什么情况,自定义的view应该是最简单的吧,没加别的代码都出错
解决方案 »
- 请问一个安卓的InflateException错误?
- 关于android自带应用的源码
- 这个"语音识别程序" 指的是什么? 是android的还是第三方的?
- cannot create /sdcard/boot.img: permission denied怎么解决
- 程序测试问题-android:sharedUserId
- 如何解决FATAL EXCEPTION: main
- 我想问一下在一个Activity里怎么干掉之前的若干个Activity?
- 关于安卓蓝牙UUID的问题
- 求教安卓应用开发的具体路线
- 各位大佬帮忙看看
- android 视频播放在快速连续选择同一个文件播放时停止播放
- 安卓怎么运行后台进程
public MyView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}