praveen
praveen

Reputation: 71

explain the seekbar listener in android

in the below could anyone please explain about the parameters passed to the listeners.that is in sbar1.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener()). thank you

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

                }
            });
        }
    }

Upvotes: 0

Views: 508

Answers (2)

Shriyansh Gautam
Shriyansh Gautam

Reputation: 1082

The Javadoc for onSeekBarChangeListener might help you understand

     /**
     * 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);

Upvotes: 1

Balaraju M
Balaraju M

Reputation: 493

SeekBar is a kind of ProgressBar with draggable thumb. The end user can drag the thum left and right to move.

Seekbar.setOnSeekBarChangeListener() interface provide methods for event handling on seekbar

Upvotes: 0

Related Questions