我有一个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));
}
};
答案 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
}