M
M
Masteron2015-10-15 18:15:15
Android
Masteron, 2015-10-15 18:15:15

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);
        }

    }
}

This code should display the animation of the balls (but not the essence). Instead, I get a hello world (well, which is created when the project is created) how to fix this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Emin, 2015-10-15
@Ewintory

First look intolayout/activity_main.xml

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question