Question

Hi I want to bind button with text with seekbar thumb. so that if I move the seekbar thumb the button with dynamic text move along with that.

enter image description here Please suggest how to do that.

Thanks in advance.

Was it helpful?

Solution

Try Something like below:

 protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_seekbar_test);

    seek = (SeekBar) findViewById(R.id.seekBar1);
    text = (TextView) findViewById(R.id.textView1);

    seek.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {       
        @Override       
        public void onStopTrackingTouch(SeekBar seekBar) {            
        }       
        @Override       
        public void onStartTrackingTouch(SeekBar seekBar) {     
        }       
        @Override       
        public void onProgressChanged(SeekBar seekBar, int progress,boolean fromUser) {
            setTxt(progress);
        }
    });
}

private void setTxt(int prg)
{
    text.setX((float)prg);
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top