SeekBar

//MainActivity

 

import android.os.Bundle;

import android.app.Activity;

import android.view.Menu;

import android.widget.SeekBar;

import android.widget.SeekBar.OnSeekBarChangeListener;

import android.widget.Toast;

public class MainActivity extends Activity implements OnSeekBarChangeListener{

    SeekBar seekBar1;

    @Override

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);

        seekBar1=(SeekBar)findViewById(R.id.seekBar1);

        seekBar1.setOnSeekBarChangeListener(this);

    }

    @Override

    public void onProgressChanged(SeekBar seekBar, int progress,boolean fromUser) {

        Toast.makeText(getApplicationContext(),"Seekbar Progress: "+progress, Toast.LENGTH_SHORT).show();

    }

    @Override

    public void onStartTrackingTouch(SeekBar seekBar) {

    }

    @Override

    public void onStopTrackingTouch(SeekBar seekBar) {

    }

}

 

//activity_main.xml

 

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

    xmlns:tools="http://schemas.android.com/tools"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    tools:context=".MainActivity" >

    <SeekBar

        android:id="@+id/seekBar1"

        android:layout_width="match_parent"

        android:layout_height="wrap_content"

        android:layout_marginTop="39dp" />

</RelativeLayout>