0
我想添加一個OnTouchListener到我的surfaceView,但我不太明白。 我試圖用android surfaceView onTouchListener
surfaceView.setOnClickListener(this);
添加OnTouchListener在MainActivity沒有結果。有什麼建議麼?
主要活動:
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.surface_view);
surfaceView= (AnimationSurface) findViewById(R.id.surfaceView);
}
SurfaceView
public class AnimationSurface extends SurfaceView implements Runnable {
SurfaceHolder Holder;
Thread Thread = null;
boolean isRunning = true;
float x=0;
float y=0;
public AnimationSurface(Context context, AttributeSet attrs) {
// TODO Auto-generated constructor stub
super(context);
Holder = getHolder();
Thread = new Thread(AnimationSurface.this);
Thread.start();
}
@Override
public void run() {
// TODO Auto-generated method stub
[...]
}
}
感謝您的時間, Maldita