luigifonti Posted February 13, 2012 Share Posted February 13, 2012 As novice Android developer, I am trying to accomplish a simple task: create a screen with bot a Button and a graphics area in which I should be able to draw geometric shapes, bitmaps... Following some suggestions I have built an application with this type of source code and main.xml file : -------------------------------------------------------- package com.marimba; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.content.Context; import android.graphics.Paint; import android.graphics.Canvas; import android.graphics.Color; public class Marimba extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); } class MyView extends View { public MyView(Context context) { super(context); } @Override protected void onDraw(Canvas c) { super.onDraw©; Paint paint = new Paint(); paint.setStyle(Paint.Style.FILL); paint.setColor(Color.BLACK); c.drawPaint(paint); // draw a circle paint.setAntiAlias(true); paint.setColor(Color.YELLOW); c.drawCircle(230, 90, 40, paint); } } } .----------------------------------------------------------- android:id="@+id/widget0" android:layout_width="fill_parent" android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android" > android:id="@+id/action" android:layout_width="160px" android:layout_height="50px" android:text="Action" android:layout_x="80px" android:layout_y="330px" /> android:id="@+id/myview" android:layout_width="303px" android:layout_height="336px" android:layout_x="9px" android:layout_y="8px" /> ------------------------------------------------------------- Well, the application compiles without error/warnings, but when launched (bot on emulator or on device), it shows an error message: Sorry. Unexpected interruption of application Marimba (process com.marimba). Retry. Can you suggest another way to have the result I need ? Thank you Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.