Using SeekBar

For adding a seekbar to your layout file (res/layout/*.xml)

        android:layout_height="wrap_content" />

For adding the functionality part of the SeekBar, copy and paste the below code in your onCreate() function of JAVA File.

Note: Below the SetContentView() line in onCreate() function.

		SeekBar sb = (SeekBar) findViewById(;
		sb.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {

			public void onStopTrackingTouch(SeekBar seekBar) {
				// TODO Auto-generated method stub
				Toast.makeText(MainActivity.this, "stop"+Integer.toString(progressed),

			public void onStartTrackingTouch(SeekBar seekBar) {
				// TODO Auto-generated method stub


			public void onProgressChanged(SeekBar seekBar, int progress,
					boolean fromUser) {
				// TODO Auto-generated method stub
				progressed = progress;

Note: Make sure you declare a variable in Java Class file. Before the function and inside the class file at top.

int progressed = 0;

Save the changes and run your Android Application in Emulator or an Android Device. Post your comments.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s