Home > Android > Android Seekbar Example | Source Code

Android Seekbar Example | Source Code

Android Seekbar Example

Android Seekbar

Android Seekbar Example

Android Seekbar Example  Android Seekbar Example

Java Code(SeekAct)

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.SeekBar;
import android.widget.TextView;

public class SeekAct extends Activity {
SeekBar sb;
TextView tv;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_seek);

tv = (TextView)findViewById(R.id.tv1);
sb = (SeekBar)findViewById(R.id.sb1);
sb.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser)
{
tv.setText(“”+progress);
}

@Override
public void onStartTrackingTouch(SeekBar seekBar){

}

@Override
public void onStopTrackingTouch(SeekBar seekBar)
{

}
});
}
public void view1(View v)
{
Intent i=new Intent(SeekAct.this,SeekNext.class);
startActivity(i);
}

}

Layout XML Code(activity_seek)

<?xml version=”1.0″ encoding=”utf-8″?>
<LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android”
xmlns:tools=”http://schemas.android.com/tools”
android:layout_width=”match_parent”
android:orientation=”vertical”
android:layout_height=”match_parent”
android:paddingBottom=”@dimen/activity_vertical_margin”
android:paddingLeft=”@dimen/activity_horizontal_margin”
android:paddingRight=”@dimen/activity_horizontal_margin”
android:paddingTop=”@dimen/activity_vertical_margin”
tools:context=”com.andro.tech.androidproject.SeekAct”>

<TextView
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:textSize=”@dimen/textsize”
android:layout_gravity=”center”
android:textStyle=”bold”
android:text=”SEEK BAR”
android:layout_marginBottom=”80dp” />

<SeekBar
android:layout_width=”match_parent”
android:layout_height=”wrap_content”
android:id=”@+id/sb1″
android:layout_marginBottom=”50dp”/>

<TextView
android:textSize=”30sp”
android:textColor=”#123″
android:textStyle=”bold”
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:text=” “
android:id=”@+id/tv1″
android:layout_gravity=”center”
android:layout_marginTop=”30dp”
android:layout_below=”@+id/sb2″
android:layout_centerHorizontal=”true”
android:layout_marginBottom=”120dp”/>

<Button
android:layout_width=”match_parent”
android:layout_height=”wrap_content”
android:text=”@string/sourcecode”
android:background=”@color/bgcolor”
android:textStyle=”bold”
android:textColor=”@color/text”
android:onClick=”view1″/>

</LinearLayout>


Output

Android Seekbar Example  Android Seekbar Example

Download Source Code

Follow Us – Never Miss Update

Fb/PageTwitterGoogle+InstagramPinterest 



Recent   

Android Seekbar Example

Leave a Reply

Your email address will not be published. Required fields are marked *

Translate »