HI,
I have an edittext which is for reading currency value.
"How do you create an edittext entry that formats input in money
format only? When the user enters 5, I want the input to look like
"$0.05" and when they then enter 3, the input should now look like
"$0.53" and finally they enter 6 and the input should look like
"$5.36"."
I did as follows:
------------------------
mUserText.addTextChangedListener(new MyTextWatcher());
and
public class MyTextWatcher implements TextWatcher {
public void afterTextChanged(Editable arg0) {
}
public void beforeTextChanged(CharSequence s, int start, int
count, int after) {
}
public void onTextChanged(CharSequence s, int start, int before,
int count) {
// here i converted to string
String userInput= ""+s.toString();
Float in=Float.parseFloat(userInput);
float percen = in/100;
Log.i("user input Text final",""+percen+" -->"+percen);
mUserText.setText(""+percen);
}
--------------------
Everything is working but the problem here is ,will report
StackOverflow exception due to the following reason
1) It will come to OnTextChanged method whenever text changed.But
after that when we try to set the formatted value in edittext ,in the
last line of the code.it will get recursive ...
mUserText.setText(""+percen);
2)It is becoming as infinate.
I hope you understood the problem.
Please help me if anybody knows the solution or any idea related to
the solution.
Thanks in advance.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en