1

我有一个 EditText,它接受来自键盘或 seekBar 的更改。我想知道,改变是从键盘输入或从 seekBar 改变。我怎样才能做到这一点?

“你是如何根据 seekbar 改变编辑文本的值的?” 回答:

  SeekBar.OnSeekBarChangeListener seekBarListener = new OnSeekBarChangeListener() {

    ...

    @Override
    public void onProgressChanged(SeekBar seekBar, int progress,
            boolean fromUser) {
        float degree = (float)progress/10;
        int value = (int) Math.pow(10, degree);
        editTextCoins.setText(String.valueOf(value));

    }

};
4

1 回答 1

0
String seekBarText;
@Override
    public void onProgressChanged(SeekBar seekBar, int progress,
            boolean fromUser) {
        float degree = (float)progress/10;
        int value = (int) Math.pow(10, degree);
        editTextCoins.setText(String.valueOf(value));
seekBarText=(String.valueOf(value));

    }

};
if(seekBarText.equals(editTextCoins.getText().toString()){
//value change from seekBar
}
else{
//value change from Keyboard
}
于 2014-05-17T10:55:14.217 回答