Android SeekBar example

The layout for the SeekBar.


    
    
    

Initialize the SeekBar in the activity or fragment. The OnSeekBarChangeListener will update the label to show the current progress of the SeekBar.

tv_radius_value.text = if (seekbar_radius.getProgress() > 1) "${seekbar_radius.getProgress()} miles" else "${seekbar_radius.getProgress()} miles"
seekbar_radius.setOnSeekBarChangeListener(object : SeekBar.OnSeekBarChangeListener {

    override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
    }

    override fun onStartTrackingTouch(seekBar: SeekBar) {}

    override fun onStopTrackingTouch(seekBar: SeekBar) {
        tv_radius_value.text = if (seekbar_radius.getProgress() > 1) "${seekbar_radius.getProgress()} miles" else "${seekbar_radius.getProgress()} miles"
    }
})

Complete example in Github

Search within Codexpedia

Custom Search

Search the entire web

Custom Search