• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Paint on canvas

I have a new component which extends View. Code:
Code:
/**
 * 
 */
package myApp.components;

import android.R;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;

/**
 * @author Admin
 *
 */
public class SquareView extends View {

	@Override
	protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
		// TODO Auto-generated method stub
		super.onMeasure(widthMeasureSpec, heightMeasureSpec);
		
		final int width = getMeasuredWidth();
		
		setMeasuredDimension(width, width);
	}

	public SquareView(Context context) {
		super(context);
		// TODO Auto-generated constructor stub
	}

	public SquareView(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		// TODO Auto-generated constructor stub
	}

	public SquareView(Context context, AttributeSet attrs) {
		super(context, attrs);
		// TODO Auto-generated constructor stub
	}
	
	public void drawField(Canvas c, int x, int y) {
		//paint			
	}

}

How to call a method drawField(Canvas c, int x, int y) and where i can take a Canvas???
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones