我不知道崩潰的原因。android上的應用程序崩潰
package com.tct.soundTouch;
//imports();;;;;;;
public class Main extends Activity implements OnClickListener{
private MediaPlayer mp;
private MotionEvent event;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main);
final ImageButton zero = (ImageButton) this.findViewById(R.id.button);
zero.setOnClickListener(this);
mp = MediaPlayer.create(this, R.raw.sound);
}
public void onClick(View v) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
mp.setLooping(true);
mp.start();
break;
case MotionEvent.ACTION_UP:
mp.pause();
break;
}
}
}
日誌
感謝
這是34行嗎? – Farrell 2011-03-14 16:36:19
第34行:switch(event.getAction()){ – anvd 2011-03-14 16:40:20
現在我100%確定我的回答是正確的:D – RoflcoptrException 2011-03-14 16:41:57