1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
| package com.ThreadTest.Affichage;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.drawable.AnimationDrawable;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.util.Log;
import android.widget.ImageView;
import com.ThreadTest.main.R;
public class Joueur extends ImageView {
protected AnimationDrawable animation ;
protected Thread currentThread ;
protected int i = 0 ;
public Joueur(Context context, AttributeSet attrs) {
super(context, attrs);
Log.e("Joueur", "Constructeur") ;
// TODO Auto-generated constructor stub
setBackgroundResource(R.layout.animationjoueur) ;
animation = (AnimationDrawable) getBackground() ;
}
public void scrollToMiddle(){
while(i < 10){
layout(getLeft(), getTop()-1, getRight(), getBottom()-1) ;
i++ ;
}
i = 0 ;
}
@Override
protected void onDraw(Canvas canvas) {
// TODO Auto-generated method stub
super.onDraw(canvas);
}
@Override
public void onWindowFocusChanged(boolean hasWindowFocus) {
// TODO Auto-generated method stub
super.onWindowFocusChanged(hasWindowFocus);
Log.e("Joueur","onWindowFocusChanged") ;
animation.start() ;
}
} |
Partager