質問

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