在我的 android 应用程序中,我将为鸟素描上色。我需要用各种颜色为鸟的每个部分着色。我用这个位图的屏幕坐标来识别那些部分。现在我需要的是,当用户触摸身体部位的区域时,然后打开另一个具有颜色列表的窗口。为此,我需要将数据从我的 View 类传递到新的 Activity 类。我怎样才能做到这一点?请帮忙!
我的视图类
class BirdColors extends View{
private Paint paint;
public Bitmap mBitmap,nBitmap;
public Canvas canvas;
private int x,y;
private CreateColorList colorList;
int val;
public BirdColors(Context context) {
super(context);
// TODO Auto-generated constructor stub
paint=new Paint();
paint.setAntiAlias(true);
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeJoin(Paint.Join.ROUND);
mBitmap=BitmapFactory.decodeResource(getResources(), R.drawable.birdsketchfinal2).copy(Config.ARGB_8888, true);
mBitmap= Bitmap.createScaledBitmap(mBitmap, 230, 230, true);
//mBitmap=nBitmap;
}
@Override
protected void onDraw(Canvas canvas) {
// TODO Auto-generated method stub
super.onDraw(canvas);
this.canvas=canvas;
canvas.drawBitmap(mBitmap,0,0, null);
//canvas.drawText("Shashika", 10, 50, paint);
canvas.drawText("Screen Cordinates" +x+"x"+y, 10, 220, paint);
}
@Override
public boolean onTouchEvent(MotionEvent event) {
// TODO Auto-generated method stub
switch(event.getAction()){
case MotionEvent.ACTION_DOWN:
x=(int)event.getX();
y=(int)event.getY();
if((x>5 && x<23)&&(y>30 && y<47)){
val=1;
//colorList=new CreateColorList(val);
//In here I need to pass the val
}
invalidate();
}
return true;
}