まず私のコードを見てください:
これらは私の活動です。
EditText text1,text2; (Are defined corretly not problem)
text1.addTextChangedListener(new MyTextWatcher(onePercent));
text2.addTextChangedListener(new MyTextWatcher(twoPercent));
.. ..
.. ..
.. ..
private class MyTextWatcher implements TextWatcher {
private View view;
private MyTextWatcher(View view) {
this.view = view;
}
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {}
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2)
{}
public void afterTextChanged(Editable editable) {
String text = editable.toString();
switch(view.getId()){
case R.id.dis_one_percent: (this is text1)
if(!text.equel(""))
text2.setText(Double.toString(text));
break;
case R.id.dis_one_number: (and text2)
if(!text.equel(""))
text1.setText(Double.toString(text+"LOL"));
}
}
}
目標: ユーザーが text1 領域に何らかの値を入力すると、text2 領域をトリガーしたいと考えています。しかし、ユーザーが text1 領域に値を入力すると、text2 の MyTextWatcher がトリガーされました。無限ループがあります。どうすればこの問題を解決できますか?