Android tutorial for beginner 5 , Seekbar | অ্যান্ড্রয়েড বাংলা টিউটোরিয়াল

  • 23 April 20
  • Posted By : Admin
  • 102 Hits
  • 10 Comment

Seekbar

}

Java code

Java code below

package com.salam.seekbar; import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle; import android.widget.SeekBar; import android.widget.TextView; public class MainActivity extends AppCompatActivity { public SeekBar seekBar; public TextView textView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); seekBar = findViewById(R.id.seekBar); textView = findViewById(R.id.textView); seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int i, boolean b) { textView.setText(String.valueOf(i)); } @Override public void onStartTrackingTouch(SeekBar seekBar) { } @Override public void onStopTrackingTouch(SeekBar seekBar) { } }); } }

Create xml file

Xml code below

<?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" tools:context=".MainActivity" android:orientation="vertical" android:gravity="center"> <SeekBar android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/seekBar" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="0" android:id="@+id/textView" android:textColor="#f00" android:textSize="180dp"/> </LinearLayout>