2017-09-13 39 views
0

中解釋seekbar listener可以請任何人解釋一下傳遞給listeners的參數,即sbar1.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener())。謝謝在下面的android

package com.example.centum.seekbar; 

    import android.support.v7.app.AppCompatActivity; 
    import android.os.Bundle; 
    import android.widget.EditText; 
    import android.widget.SeekBar; 

    public class MainActivity extends AppCompatActivity { 

     EditText etext1; 
     SeekBar sbar1; 
     @Override 
     protected void onCreate(Bundle savedInstanceState) { 
      super.onCreate(savedInstanceState); 
      setContentView(R.layout.activity_main); 
      etext1=(EditText)findViewById(R.id.et2); 
      sbar1=(SeekBar)findViewById(R.id.sb2); 
      sbar1.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { 
       @Override 
       public void onProgressChanged(SeekBar seekBar, int i, boolean b) { 
        etext1.setTextSize(i*5); 
       } 

       @Override 
       public void onStartTrackingTouch(SeekBar seekBar) { 

       } 

       @Override 
       public void onStopTrackingTouch(SeekBar seekBar) { 

       } 
      }); 
     } 
    } 
+0

請詳細問清楚你的問題 –

回答

0

搜索欄是一種進度與拖動拇指。最終用戶可以拖動胸圍左右移動。

Seekbar.setOnSeekBarChangeListener()接口提供處理的搜索條

1

事件方法onSeekBarChangeListener的Javadoc可能會幫助你瞭解

 /** 
    * Notification that the progress level has changed. Clients can use the fromUser parameter 
    * to distinguish user-initiated changes from those that occurred programmatically. 
    * 
    * @param seekBar The SeekBar whose progress has changed 
    * @param progress The current progress level. This will be in the range 0..max where max 
    *  was set by {@link ProgressBar#setMax(int)}. (The default value for max is 100.) 
    * @param fromUser True if the progress change was initiated by the user. 
    */ 
    void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser); 

    /** 
    * Notification that the user has started a touch gesture. Clients may want to use this 
    * to disable advancing the seekbar. 
    * @param seekBar The SeekBar in which the touch gesture began 
    */ 
    void onStartTrackingTouch(SeekBar seekBar); 

    /** 
    * Notification that the user has finished a touch gesture. Clients may want to use this 
    * to re-enable advancing the seekbar. 
    * @param seekBar The SeekBar in which the touch gesture began 
    */ 
    void onStopTrackingTouch(SeekBar seekBar);