[問題] 模擬器一直跑出error
開發層: (應用/框架/庫/核心)
問題:
再寫一個簡單的圖形繪製,不過模擬器那邊一直跑出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)
→
06/24 00:07, , 1F
06/24 00:07, 1F
→
06/24 00:16, , 2F
06/24 00:16, 2F
推
06/24 01:40, , 3F
06/24 01:40, 3F
推
06/25 03:53, , 4F
06/25 03:53, 4F
→
06/25 03:54, , 5F
06/25 03:54, 5F
→
06/25 03:55, , 6F
06/25 03:55, 6F
AndroidDev 近期熱門文章
PTT數位生活區 即時熱門文章