私はユーザーが画面に触れ、ユーザーの指の座標に基づいてイメージを描くことを可能にするアプリケーションを作ろうとしています。私はandroid drawing on touchイベント
public class DrawingBoard extends View {
Drawable editIcon = getResources().getDrawable(R.drawable.icon);
Bitmap mBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.background);
float xPos = 0;
float yPos = 0;
public DrawingBoard (Context context) {
// TODO Auto-generated constructor stub
super (context);
}
@Override
protected void onDraw (Canvas canvas) {
super.onDraw(canvas);
canvas.save();
canvas.drawBitmap(mBitmap, 0, 0, null);
canvas.translate(xPos, yPos);
editIcon.draw(canvas);
canvas.restore();
invalidate();
}
@Override
public boolean onTouchEvent (MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN :
xPos = event.getX();
yPos = event.getY();
break;
}
return true;
}
}
}
しかし、私はエミュレータの画面上でクリックしてくださいいつでも、示さ全くイメージがありません....
のplsは私のミスを指摘... THX
で
invalidate()
を持っていません? –@SimonAndréForsbergDude、なぜあなたはこのanswer.areであなたに投票を下すのですか?あなたは見えません。このコードはGoogleマップオンタッチイベントで画像を描画します。あなたに何が問題なのか分かりません。あなたがそれを理解していないなら、私に馬を作りなさい、私はそれを詳述するでしょう。 –