1.package com.ray.test;
2./*
3. * SurfaceView的示例程序
4. * 演示其流程
5. */
6.import android.app.Activity;
7.import android.content.Context;
8.import android.graphics.Canvas;
9.import android.graphics.Color;
10.import android.graphics.Paint;
11.import android.graphics.RectF;
12.import android.os.Bundle;
13.import android.view.SurfaceHolder;
14.import android.view.SurfaceView;
15.
16.public class Test extends Activity {
17. public void onCreate(Bundle savedInstanceState) {
18. super.onCreate(savedInstanceState);
19. setContentView(new MyView(this));
20. }
21.
22. //内部类
23. class MyView extends SurfaceView implements SurfaceHolder.Callback{
24.
25. SurfaceHolder holder;
26. public MyView(Context context) {
27. super(context);
28. holder = this.getHolder();//获取holder
29. holder.addCallback(this);
30. //setFocusable(true);
31.
32. }
33.
34. @Override
35. public void surfaceChanged(SurfaceHolder holder, int format, int width,
36. int height) {
37.
38. }
39.
40. @Override
41. public void surfaceCreated(SurfaceHolder holder) {
42. new Thread(new MyThread()).start();
43. }
44.
45. @Override
46. public void surfaceDestroyed(SurfaceHolder holder) {
47.
48. }
49.
50. //内部类的内部类