Android SeekBar - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android SeekBar class.

This code example shows how to use the following methods:setMax, setProgress, setOnSeekBarChangeListener
 
    @Override 
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().setBackgroundDrawable(new ColorDrawable(0xff000000));
        SeekBar slider = new SeekBar(this);
        LinearLayout container = new LinearLayout(this);
        container.setOrientation(LinearLayout.VERTICAL);
        setContentView(container);
 
        container.addView(slider);
        slider.setMax(100);
        slider.setProgress(50);
        FrameLayout frame = new FrameLayout(this);
        final RenderingView gpuView = new RenderingView(this, Color.GREEN);
        frame.addView(gpuView);
        final RenderingView swView = new RenderingView(this, Color.RED);
        swView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
        frame.addView(swView);
        container.addView(frame);

8
CodeRank
This code example shows how to use the following methods:setMax, setProgress
			return layout;
		} 
	@Override 
		protected void onBindDialogView(View v) {
			super.onBindDialogView(v);
			mSeekBar.setMax(mMax);
			mSeekBar.setProgress(mValue);
		} 
	@Override 
		protected void onSetInitialValue(boolean restore, Object defaultValue)
		{ 
			super.onSetInitialValue(restore, defaultValue);
			if (restore)
				mValue = shouldPersist() ? getPersistedInt(mDefault) : 0;
			else 
				mValue = (Integer)defaultValue;
		} 
 
	public void onProgressChanged(SeekBar seek, int value, boolean fromTouch)
	{ 
8
CodeRank
This code example shows how to use the following methods:setProgress
                      green.getProgress(), blue.getProgress()));
  } 
   
  public void setColor(int color) {
    red.setProgress(Color.red(color));
    green.setProgress(Color.green(color));
    blue.setProgress(Color.blue(color));
    swatch.setBackgroundColor(color);
  } 
   
  private SeekBar.OnSeekBarChangeListener onMix=new SeekBar.OnSeekBarChangeListener() {
    public void onProgressChanged(SeekBar seekBar, int progress, 
                                  boolean fromUser) { 
      int color=getColor(); 
       
      swatch.setBackgroundColor(color); 
       
      if (listener!=null) { 
        listener.onColorChange(color); 
      } 
8
CodeRank
This code example shows how to use the following methods:setLayoutParams, setPadding, setMax, setProgress, setOnSeekBarChangeListener
		mValueText = new TextView(context);
		mValueText.setGravity(Gravity.RIGHT);
		mValueText.setPadding(20, 0, 20, 0);
		layout.addView(mValueText);
 
		SeekBar seekBar = new SeekBar(context);
		seekBar.setPadding(20, 0, 20, 20);
		seekBar.setLayoutParams(params);
		seekBar.setMax(1000);
		seekBar.setProgress((int)(Math.pow((float)(mValue - MIN) / (MAX - MIN), 0.25f) * 1000));
		seekBar.setOnSeekBarChangeListener(this);
		layout.addView(seekBar);
 
		updateText(); 
 
		builder.setView(layout);
	} 
 
	/** 
	 * Format seconds into a human-readable time description. 
8
CodeRank
This code example shows how to use the following methods:setMax, setProgress
    } 
 
    @Override 
    protected void onBindDialogView(View v) {
        super.onBindDialogView(v);
        mSeekBar.setMax(mMax);
        mSeekBar.setProgress(mValue);
    } 
 
    @Override 
    protected void onSetInitialValue(boolean restore, Object defaultValue) {
        super.onSetInitialValue(restore, defaultValue);
        if (restore)
            mValue = shouldPersist() ? getPersistedInt(mDefault) : mMin;
        else 
            mValue = ((Integer)defaultValue > mMin) ? (Integer)defaultValue : mMin;
    } 
 
    public void onProgressChanged(SeekBar seek, int value, boolean fromTouch) {
        String t = "";
8
CodeRank
This code example shows how to use the following methods:setProgress
                      green.getProgress(), blue.getProgress()));
  } 
   
  public void setColor(int color) {
    red.setProgress(Color.red(color));
    green.setProgress(Color.green(color));
    blue.setProgress(Color.blue(color));
    swatch.setBackgroundColor(color);
  } 
   
  private SeekBar.OnSeekBarChangeListener onMix=new SeekBar.OnSeekBarChangeListener() {
    public void onProgressChanged(SeekBar seekBar, int progress, 
                                  boolean fromUser) { 
      int color=getColor(); 
       
      swatch.setBackgroundColor(color); 
       
      if (listener!=null) { 
        listener.onColorChange(color); 
      } 
8
CodeRank
This code example shows how to use the following methods:setMax, setProgress, setOnSeekBarChangeListener
 
    @Override 
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().setBackgroundDrawable(new ColorDrawable(0xff000000));
        SeekBar slider = new SeekBar(this);
        LinearLayout container = new LinearLayout(this);
        container.setOrientation(LinearLayout.VERTICAL);
        setContentView(container);
 
        container.addView(slider);
        slider.setMax(100);
        slider.setProgress(50);
        FrameLayout frame = new FrameLayout(this);
        final RenderingView gpuView = new RenderingView(this, Color.GREEN);
        frame.addView(gpuView);
        final RenderingView swView = new RenderingView(this, Color.RED);
        swView.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
        frame.addView(swView);
        container.addView(frame);

8
CodeRank
This code example shows how to use the following methods:setMax, setProgress
	} 
 
	@Override 
	protected void onBindDialogView(final View v) {
		super.onBindDialogView(v);
		seekBar.setMax(maxValue);
		seekBar.setProgress(value);
	} 
 
	@Override 
	protected View onCreateDialogView() {
		LinearLayout.LayoutParams params;
		final LinearLayout layout = new LinearLayout(context);
		layout.setOrientation(LinearLayout.VERTICAL);
		layout.setPadding(6, 6, 6, 6);
 
		dialogTextView = new TextView(context);
		if (dialogText != null) {
			dialogTextView.setText(dialogText);
		} 
8
CodeRank
This code example shows how to use the following methods:setLayoutParams, setMax, setProgress, setOnSeekBarChangeListener
This code example shows how to use the following methods:getProgress
        final Parcelable superState = super.onSaveInstanceState();
        if (getDialog() == null || !getDialog().isShowing()) return superState;
 
        // Save the dialog state 
        final SavedState myState = new SavedState(superState);
        myState.progress = mSeekBar.getProgress();
        myState.oldSpeed = mOldSpeed;
 
        // Restore the old state when the activity or dialog is being paused 
        restoreOldState(); 
        return myState;
    } 
 
    @Override 
    protected void onRestoreInstanceState(Parcelable state) {
        if (state == null || !state.getClass().equals(SavedState.class)) {
            // Didn't save state for us in onSaveInstanceState 
            super.onRestoreInstanceState(state);
            return; 
        } 
8
CodeRank

Related Android SeekBar Questions & Answers:

Other Android SeekBar Examples

32:		@Override
33:		public void onProgressChanged(SeekBar seekBar, int progress, boolean fromTouch) {
34:	
35:		}
36:	
-
40:		@Override
41:		public void onStartTrackingTouch(SeekBar seekBar) {
42:			// remove message Handler from updating progress bar
43:			mHandler.removeCallbacks(mUpdateTimeTask);
44:	    }
-
49:		@Override
50:	    public void onStopTrackingTouch(SeekBar seekBar) {
51:			mHandler.removeCallbacks(mUpdateTimeTask);
52:			int totalDuration = mp.getDuration();
53:			int currentPosition = utils.progressToTimer(seekBar.getProgress(), totalDuration);

Read More

27:		private ImageButton btnShuffle;
28:		private SeekBar songProgressBar;
29:		private TextView songTitleLabel;
30:		private TextView songCurrentDurationLabel;
31:		private TextView songTotalDurationLabel;
-
58:			btnShuffle = (ImageButton) findViewById(R.id.btnShuffle);
59:			songProgressBar = (SeekBar) findViewById(R.id.songProgressBar);
60:			songTitleLabel = (TextView) findViewById(R.id.songTitle);
61:			songCurrentDurationLabel = (TextView) findViewById(R.id.songCurrentDurationLabel);
62:			songTotalDurationLabel = (TextView) findViewById(R.id.songTotalDurationLabel);
-
295:				e.printStackTrace();
296:			} catch (IllegalStateException e) {
297:				e.printStackTrace();
298:			} catch (IOException e) {
299:				e.printStackTrace();
-
303:		/**
304:		 * Update timer on seekbar
305:		 * */
306:		public void updateProgressBar() {
307:	        mHandler.postDelayed(mUpdateTimeTask, 100);
-
312:		 * */
313:		private Runnable mUpdateTimeTask = new Runnable() {
314:			   public void run() {
315:				   long totalDuration = mp.getDuration();
316:				   long currentDuration = mp.getCurrentPosition();

Read More

See Code Examples for Android SeekBar Methods: