作者steven9374 (steven)
看板AndroidDev
标题[问题] 模拟器一直跑出error
时间Thu Jun 23 23:56:26 2011
开发层: (应用/框架/库/核心)
问题:
再写一个简单的图形绘制,不过模拟器那边一直跑出The application has stopped
unexpectedly.Please try again.
输入:
预期输出:
错误输出:
错误讯息:
程式码: (请多利用置底文网站)
package android.com;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.view.View;
public class myview extends View {
/** Called when the activity is first created. */
public myview(Context context,AttributeSet attrs)
{
super(context,attrs);
}
protected void onDraw(Canvas canvas)
{
super.onDraw(canvas);
canvas.drawColor(Color.BLACK);
Paint paint=new Paint();
paint.setColor(Color.RED);
canvas.drawRect(10, 10,110,110,paint);
canvas.drawText("加油",10,130,paint);
RectF rf1=new RectF(10,130,110,230);
canvas.drawArc(rf1,0,45,true,paint);
canvas.drawLine(150,10,250,110,paint);
RectF rf2=new RectF(150,130,110,230);
canvas.drawOval(rf2,paint);
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="
http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<android.com.myview
android:id="@+id/vieww"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</LinearLayout>
我是android新手 不知道是哪里出了问题,我也是都照着书本打上去的
请大家帮帮忙~
感谢
参考: (书籍/网页/...)
补充说明:
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 59.126.1.145
※ 编辑: steven9374 来自: 59.126.1.145 (06/24 00:03)
1F:→ chiwa:建议你先把这本书丢了 06/24 00:07
2F:→ steven9374:假真,我刚买耶 06/24 00:16
3F:推 jim31837:你要不要先用内建的view就好 有必要自己画吗? 06/24 01:40
4F:推 chiwa:你用eclipse开发吗?要不要试着自己开个新的android project 06/25 03:53
5F:→ chiwa:先确定可以执行之後,再把书上的程式码加上去 06/25 03:54
6F:→ chiwa:看你PO的程式码实在不知道要从何讲起... 06/25 03:55