Home » Android » java – Get android seekbar value and display it on screen

java – Get android seekbar value and display it on screen

Posted by: admin April 23, 2020 Leave a comment


I’m trying to get the value of the seek bar whenever it changes and display it underneath. I’m using the onclick method on my seekbar to call this method.

public void getNumber(View view) 
    SeekBar seek = (SeekBar) findViewById(R.id.seekBar1);
    int seekValue = seek.getProgress();
    String x = "Value: " + Integer.toString(seekValue);
    ((TextView) findViewById(R.id.level)).setText(x);
How to&Answers:

Here some extra help:

import android.app.Activity; 
import android.os.Bundle; 
import android.widget.SeekBar; 
import android.widget.TextView; 

public class AndroidSeekBar extends Activity { 
   /** Called when the activity is first created. */ 
   public void onCreate(Bundle savedInstanceState) 

       SeekBar seekBar = (SeekBar)findViewById(R.id.seekbar); 
       final TextView seekBarValue = (TextView)findViewById(R.id.seekbarvalue); 

       seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener(){ 

   public void onProgressChanged(SeekBar seekBar, int progress, 
     boolean fromUser) { 
    // TODO Auto-generated method stub 

   public void onStartTrackingTouch(SeekBar seekBar) { 
    // TODO Auto-generated method stub 

   public void onStopTrackingTouch(SeekBar seekBar) { 
    // TODO Auto-generated method stub 

use the OnProgressChanged event to check the progress of the seekbar, you can return that int to use it somewhere else in your app.