
Help would be very much appreciated.
I would like the code below simply to move the circle + 50 in the x axis:
- Code: Select all
package com.android.test;
import android.app.Activity;
import android.os.Bundle;
import android.view.*;
import android.graphics.*;
import android.content.Context;
public class Test extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
DrawableView dv = new DrawableView(this);
setContentView(dv);
}
public class DrawableView extends View implements View.OnTouchListener{
Context mContext;
int x = 0;
public DrawableView(Context context) {
super(context);
mContext = context;
}
protected void onDraw(Canvas canvas){
Paint myPaint = new Paint();
myPaint.setStrokeWidth(3);
myPaint.setColor(0xFF097286);
canvas.drawCircle(x, 200, 50, myPaint);
invalidate();
}
@Override
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
x +=50;
return false;
}
}
}


