Jump to content
Android Forum - A Community For Android Users and Enthusiasts

Screen with Button and graphics area


luigifonti
 Share

Recommended Posts

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"

>

-------------------------------------------------------------

 

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

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...