FaceView.java
public class FaceView extends View {
private float radius;
NormalFace normalFace;
HappyFace happyFace;
public FaceView(Context context, AttributeSet attrs) {
super(context, attrs);
// get radius value
TypedArray a = context.getTheme().obtainStyledAttributes(
attrs,
R.styleable.FaceView,
0, 0
);
try {
radius = a.getDimension(R.styleable.FaceView_radius, 20.0f);
} finally {
a.recycle();
}
// initiate HappyFace class
normalFace = new NormalFace(radius);
happyFace = new HappyFace(radius);
}
Handler setDelay;
Runnable startDelay;
@Override
protected void onDraw(final Canvas canvas) {
super.onDraw(canvas);
normalFace.draw(canvas);
//delay timer
setDelay = new Handler();
startDelay = new Runnable() {
@Override
public void run() {
happyFace.draw(canvas);
}
};
setDelay.postDelayed(startDelay,5000);
}
FaceView.java is to display the different facial expressions in the canvas. I want to add a delay timer in FaceView.java so that the display of the normal face can be change to a happy face after the timer had finished counting down.
But the app was forced to shut down. Can anybody help me with this?