You can create a SeekBar in your main.xml file just like any other component - a simple
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:progressDrawable="@color/clear_translucent"
android:background="@color/dark_blue_seek_bar"
android:progress="40"/>
The progress property in the SeekBar specifies what the initial value will be.
Next, I wanted to be able to take the present location of the SeekBar and turn it into some kind of meaningful information. To do this, I created an OnSeekBarChangeListener. This class has three methods you need to override - onProgressChanged, onStartTrackingTouch, and onStopTrackingTouch. onProgressChange is where the magic happens. The 'progress' parameter in this method represents the location on the SeekBar with 0 being the far left side and 100 being the far right. I wanted the use my SeekBar to find a number between 0 and 20 and assign it to another text box, so I implemented onProgressChange like this -
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromTouch) {
seekbarConvertedValue.setText(String.valueOf(Math.round(progress / 5)));
}
With this in place, as I move the progress indicator left and right on the SeekBar, I see my textbox update to reflect the current position.