Answer the question
In order to leave comments, you need to log in
Doesn't output what it should?
There is a code:
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public class MyView extends View {
public MyView(Context context) {
super(context);
MyTimer timer = new MyTimer();
timer.start();
}
int x = 0;
void nextFrame() {
x += 5;
invalidate();
}
class MyTimer extends CountDownTimer {
MyTimer() {
super(100000, 100);
}
@Override
public void onTick(long millisUntilFinished) {
nextFrame();
}
@Override
public void onFinish(){
}
}
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
Paint paint = new Paint();
canvas.drawCircle(x, 200, 20, paint);
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question