解释android

时间:2017-09-13 19:02:26

标签: android

在下面可以请任何人解释传递给听众的参数。这是sbar1.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener())。谢谢

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) {

                }
            });
        }
    }

2 个答案:

答案 0 :(得分: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);

答案 1 :(得分:0)

SeekBar是一种带有可拖动拇指的ProgressBar。最终用户可以左右拖动thum来移动。

Seekbar.setOnSeekBarChangeListener()接口提供搜索栏上事件处理的方法

相关问题