當我點擊開始按鈕報警開始時,當我點擊停止,它停止,但當我再次點擊開始時,報警將無法啓動。請幫助我。下面的代碼:報警按鈕點擊
public class alarm : Activity
{
protected MediaPlayer _player;
protected override void OnCreate (Bundle bundle)
{
_player = MediaPlayer.Create (this,Resource.Raw.police_alarm);
base.OnCreate (bundle);
SetContentView (Resource.Layout.alarm);
Button start = FindViewById<Button> (Resource.Id.Start_ALarm);
start.Click += delegate {
_player.Start();
};
Button stop = FindViewById<Button> (Resource.Id.Stop_ALarm);
stop.Click += delegate {
_player.Stop();
};
// FindViewById<TextView> (Resource.Id.Start_ALarm).Click+=Start_alarm_click;
//FindViewById<TextView> (Resource.Id.Stop_ALarm).Click += Stop_alarm_click;
// Create your application here
}
//FindViewById<TextView> (Resource.Id.Start_ALarm).Click+=Start_alarm_click;
public void Start_alarm_click(object sender, EventArgs eventArgs)
{
_player.Start();
}
public void Stop_alarm_click(object sender, EventArgs eventArgs)
{
_player.Stop();
}
}