I have a new component which extends View. Code:
How to call a method drawField(Canvas c, int x, int y) and where i can take a Canvas???
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???