我怎么知道,EditText上的价值如何变化

时间:2014-05-17 10:21:39

标签: android android-edittext android-seekbar

我有一个EditText,它接受来自键盘或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));

    }

};

1 个答案:

答案 0 :(得分: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
}