2011-12-14 57 views
0

我想創建一個Mono for Android應用程序的seekbar,允許用戶選擇並且我想實現SeekBar Widget,我怎樣才能在單聲道上使用SeekBarChangeListener()for Android?單聲道的SeekBar for Android

回答

2

自己寫的一個變化監聽需要實現SeekBar.IOnSeekBarChangeListener類:

public class SeekBarListener : Java.Lang.Object, SeekBar.IOnSeekBarChangeListener 
{ 
    public void OnProgressChanged(SeekBar seekBar, int progress, bool fromUser) 
    { 
    } 

    public void OnStartTrackingTouch(SeekBar seekBar) 
    { 
    } 

    public void OnStopTrackingTouch(SeekBar seekBar) 
    { 
    } 
} 

然後你就可以分配到搜索欄:

seekBar.SetOnSeekBarChangeListener(new SeekBarListener()); 
+0

謝謝,但它拋出我錯了,當我想這樣做\t txtCache.SetText(progress,Button.BufferType.Normal);繼承另一個活動cuz im在對話框中創建這個seekbar。 – arkmetal 2011-12-16 20:03:29

0

嗯,我在同一個班級解決這個實施SeekBar.IOnSeekBarChangeListener在另一種方式是我的代碼:

private void CreateDialogSeek() 
    { 

     dialogSeek = new Dialog(this); 
     dialogSeek.SetContentView(Resource.Layout.seekbar_dialog); 
     dialogSeek.SetTitle("Change your configuration"); 
     dialogSeek.SetCancelable(true); 
      //Ok 
      btnOk = (Button)(dialogSeek.FindViewById(Resource.Id.btnSettingsOKSeekBar)); 
      btnCancel = (Button)(dialogSeek.FindViewById(Resource.Id.btnSettingsCancelSeekBar)); 
      SeekBar mSeekBar = (SeekBar)(dialogSeek.FindViewById(Resource.Id.seekbar)); 
      mSeekBar.Progress = cache; 
      mSeekBar.SetOnSeekBarChangeListener(this); 

     dialogSeek.Show(); 
     btnOk.Click += delegate {OKSeek();}; 
     btnCancel.Click += delegate {dialogSeek.Dismiss();;}; 
    } 

    public void OnProgressChanged(SeekBar seekBar, int progress, bool fromUser) 
    { 
     cache = progress; 
    } 

    public void OnStartTrackingTouch(SeekBar seekBar) 
    { 
    } 

    public void OnStopTrackingTouch(SeekBar seekBar) 
    { 
    } 
+0

和OKSeek()方法,我可以把這個代碼拖到我一個錯誤.... txtCache.SetText(cache.ToString(),Button.BufferType.Normal); – arkmetal 2011-12-20 15:02:52