Blog purpose for android basic example for android app developer. any query please my contact

Wednesday, 21 April 2021

android studio seekbar example

 android studio seekbar example


today learn Android studio android studio seekbar example  SeekBar is a type of ProgressBar with a thumbs up. The end user can drag the thumb left and right to move the song progress, download the file etc.


SeekBar interface.OnSeekBar ChangeListener provides ways to make and even host a search bar.


Android SeekBar and Rating Bar classes are sub-categories of Abs SeekBar.


For Android, SeekBar is a Progress Bar extension that adds a thumb drag, the user can touch the thumb and drag left or right to set the current progress value.



SeekBar. OnSeekBar ChangeListener is a listener used as a call back that notifies the client when the progress bar of the search bar has been changed. This listener can be used for both user changes (xml file or Java category) as well as program changes.



SeekBar is a ProgressBar extension that adds a thumbs up. The user can touch the thumb and drag left or right to set the current level of progress or use the arrow keys. Placing widgets that can focus to the left or right of the SeBBar is not recommended.



If you see the result above, we can begin to show the progress of the work in the search area when we click on it in the Android app.




onProgress Changed: 

In this way progress is changed and according to this change the value of continuity can be applied to our concept.


onStart Tracking Touch:

 This way when the user starts dragging, then this option will be called automatically.


onStopTrackingTouch: 

This way, when the user stops dragging, then this method will automatically charge.



1.Open Android Studio Click Create a New Project :





2.Click Empty Activity and click Next






3.Rename Project name and Package Name Click Finish:






4.Seekbar.java:

package com.akash.myapplication;


import androidx.appcompat.app.AppCompatActivity;


import android.os.Bundle;

import android.widget.SeekBar;

import android.widget.Toast;


public class Seekbar extends AppCompatActivity {

    SeekBar seekBar;

    @Override

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_seekbar);

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

        seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {

            @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) {

                Toast.makeText(getApplicationContext(),"seekbar touch started!", Toast.LENGTH_SHORT).show();

            }


            @Override

            public void onStopTrackingTouch(SeekBar seekBar) {

                Toast.makeText(getApplicationContext(),"seekbar touch stopped!", Toast.LENGTH_SHORT).show();

            }

        });

    }

}




5.activity_seekbar.xml:


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

<androidx.constraintlayout.widget.ConstraintLayout 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"

    tools:context=".Seekbar">


    <SeekBar

        android:id="@+id/seekBar"

        android:layout_width="match_parent"

        android:layout_height="wrap_content"

        android:layout_marginEnd="8dp"

        android:layout_marginStart="8dp"

        android:layout_marginTop="372dp"

        app:layout_constraintEnd_toEndOf="parent"

        app:layout_constraintStart_toStartOf="parent"

        app:layout_constraintTop_toTopOf="parent" />


</androidx.constraintlayout.widget.ConstraintLayout>



6.AndroidManifest.xml:

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

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

    package="com.akash.myapplication">


    <application

        android:allowBackup="true"

        android:icon="@mipmap/ic_launcher"

        android:label="@string/app_name"

        android:roundIcon="@mipmap/ic_launcher_round"

        android:supportsRtl="true"

        android:theme="@style/AppTheme">

        <activity android:name=".Seekbar">

            <intent-filter>

                <action android:name="android.intent.action.MAIN" />


                <category android:name="android.intent.category.LAUNCHER" />

            </intent-filter>

        </activity>

    </application>


</manifest>


7.colors.xml:

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

<resources>

    <color name="colorPrimary">#6200EE</color>

    <color name="colorPrimaryDark">#3700B3</color>

    <color name="colorAccent">#03DAC5</color>

</resources>



8.strings.xml:

<resources>

    <string name="app_name"> android studio seekbar example</string>

</resources>



9.Output:


android studio seekbar example








android studio seekbar example

No comments:

Post a Comment