Application Get Freeze Whete Set Double Value To Edit Text Using Typewriter For 2 Edit Text
I am developeing app where i want to change the currency value from one to another, Like i have 2 edittext. one for USD Currency to enter and other for EURO currency to enter. Now
Solution 1:
It is because you get infinite loop.
amount2ET.setText will toggle another "afterTextChanged" let you repeat and repeat call of Start_Calculate.
You should remove the listener before set the text
amountET.removeTextChangedListener(inputTextWatcher)
try
{
amountET.setText(""+total);//_amount_to_send);
}
catch(Exception e)
{
Log.e("Error in Calculate-2: ",""+e.getMessage());
}
amountET.addTextChangedListener(inputTextWatcher);
Or you can set a global flag true when updating so you can dismiss another Start_Calculate:
boolean updating = false;
publicvoidafterTextChanged(Editable s)
{
try {
if (!updating)
Start_Calculate(""+s.toString());
}
catch (NumberFormatException nfe)
{ //or whatever exception you get
}
//do some handling if you need to
}
Inside Start_Calculate:
updating = true;
try
{
amountET.setText(""+total);//_amount_to_send);
}
catch(Exception e)
{
Log.e("Error in Calculate-2: ",""+e.getMessage());
}
updating = false;
Post a Comment for "Application Get Freeze Whete Set Double Value To Edit Text Using Typewriter For 2 Edit Text"