Code example for SeekBar

Methods: setProgresssetOnSeekBarChangeListener, setMax

0
				LinearLayout.LayoutParams.FILL_PARENT, 
				LinearLayout.LayoutParams.WRAP_CONTENT);
		layout.addView(mValueText, params);
 
		mSeekBar = new SeekBar(mContext);
		mSeekBar.setOnSeekBarChangeListener(this);
		layout.addView(mSeekBar, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
 
		if (shouldPersist()) 
			mValue = getPersistedInt(mDefault);
 
		mSeekBar.setMax(mMax);
		mSeekBar.setProgress(mValue);
		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)
	{ 
		String t = String.valueOf(value);
		mValueText.setText(mSuffix == null ? t : t.concat(mSuffix));
		if (shouldPersist()) 
			persistInt(value);
		callChangeListener(Integer.valueOf(value));
	} 
	public void onStartTrackingTouch(SeekBar seek) {}
	public void onStopTrackingTouch(SeekBar seek) {}
 
	public void setMax(int max) { mMax = max; }
	public int getMax() { return mMax; }
 
	public void setProgress(int progress) { 
		mValue = progress;
		if (mSeekBar != null)
			mSeekBar.setProgress(progress); 
	} 
	public int getProgress() { return mValue; }
}