info@thistimebd.com

Thursday 21st of November 06:43:10pm

Seek bar android app studio source code free download

package com.thistimebd.web.seekbar;


import android.support.v7.app.AppCompatActivity;

import android.os.Bundle;

import android.widget.SeekBar;

import android.widget.TextView;

import android.widget.Toast;


public class MainActivity extends AppCompatActivity {

    private SeekBar seekBar;

    private TextView textView;


    @Override

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);

        seekBar=(SeekBar) findViewById(R.id.seekBarId);

        textView=(TextView) findViewById(R.id.textViewId);

        textView.setText("Volume : " +seekBar.getProgress()+"/"+seekBar.getMax());


        seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

            @Override

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


                textView.setText("Volume : " +progress+"/"+seekBar.getMax());


            }


            @Override

            public void onStartTrackingTouch(SeekBar seekBar) {

                Toast.makeText(MainActivity.this, "onStartTrackingTouch",Toast.LENGTH_SHORT).show();


            }


            @Override

            public void onStopTrackingTouch(SeekBar seekBar) {

                Toast.makeText(MainActivity.this, "onStopTrackingTouch",Toast.LENGTH_SHORT).show();


            }

        });


    }

}

==============================================

activity_main.xml

--------------------

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

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

    xmlns:app="http://schemas.android.com/apk/res-auto"

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

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    android:orientation="vertical"

    android:padding="20dp"

    tools:context="com.thistimebd.web.seekbar.MainActivity">


    <SeekBar

        android:layout_gravity="center_horizontal"

        android:id="@+id/seekBarId"

        android:layout_width="200dp"

        android:layout_height="wrap_content"

        android:max="10"

        android:thumbTint="#8834ceed"

        />


<TextView

    android:layout_marginTop="20dp"

    android:layout_gravity="center_horizontal"

    android:id="@+id/textViewId"

    android:layout_width="wrap_content"

    android:layout_height="wrap_content"

    android:textSize="20sp"

    android:textStyle="bold"

    />



</LinearLayout>