我已经学习了一个星期的android。我正在编写一个简单的程序来画一个圆圈。但是当我运行它时,它告诉我程序已经停止。我一遍又一遍地阅读代码,但找不到错误。你能帮我么。
package org.example.viewwithlines;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.View;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
static public class GraphicsView extends View
{
Paint p;
public GraphicsView(Context context) {
super(context);
p=new Paint();
p.setColor(Color.MAGENTA);
}
@Override
protected void onDraw(Canvas canvas) {
canvas.drawCircle(30, 40, 10, p);
}
}
}
这是xml文件
<LinearLayout 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"
android:orientation="vertical">
<org.example.viewwithlines.MainActivity.GraphicsView
android:id="@+id/graphics" android:layout_width="fill_parent" android:layout_height="fill_parent"/>
</LinearLayout>