문제

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.

도움이 되었습니까?

해결책

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);
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top