Note that there are some explanatory texts on larger screens.

plurals
  1. POandroid EditText format as i type
    text
    copied!<p>I have this problem, how can I format the display on edittext as i type on it? for example if i type 5 it will format for desired currency. i can format the text in edittext without problem on onFocusChangeListener but the client needs onchange. </p> <p>here are some code:</p> <pre><code> &lt;code&gt; inputText = (EditText) findViewById(R.id.et_compare_rate_saving); inputText.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { //System.out.println("beforeTextChanged::: =&gt; "+charSequence); } @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { //System.out.println("onTextChanged::: =&gt; "+charSequence); } @Override public void afterTextChanged(Editable editable) { if(!editable.toString().isEmpty()){ String amount = LO.removeSeparators(editable.toString(), getLocaleFormat()); String newFormat = LO.compareRatesFormatting(Double.valueOf(amount),getLocaleFormat()); System.out.println("afterTextChanged::: =&gt; "+newFormat); inputText.setText(newFormat); } //System.out.println("afterTextChanged::: =&gt; "+editable.toString()); } }); &lt;/code&gt; </code></pre> <p>im having a stackoverflow error</p> <pre><code> &lt;code&gt; 08-01 22:37:32.724: ERROR/AndroidRuntime(1566): FATAL EXCEPTION: main java.lang.StackOverflowError at android.view.View.addFocusables(View.java:4311) at android.view.ViewGroup.addFocusables(ViewGroup.java:731) at android.view.ViewGroup.addFocusables(ViewGroup.java:731) at android.view.ViewGroup.addFocusables(ViewGroup.java:731) at android.view.ViewGroup.addFocusables(ViewGroup.java:731) at android.view.ViewGroup.addFocusables(ViewGroup.java:731) at android.view.ViewGroup.addFocusables(ViewGroup.java:731) at android.view.ViewGroup.addFocusables(ViewGroup.java:731) at android.view.ViewGroup.addFocusables(ViewGroup.java:731) at android.view.ViewGroup.addFocusables(ViewGroup.java:731) at android.view.ViewGroup.addFocusables(ViewGroup.java:712) at android.view.View.getFocusables(View.java:4269) at android.view.FocusFinder.findNextFocus(FocusFinder.java:114) at android.view.FocusFinder.findNextFocus(FocusFinder.java:98) at android.view.ViewGroup.focusSearch(ViewGroup.java:570) at android.view.ViewGroup.focusSearch(ViewGroup.java:572) at android.view.ViewGroup.focusSearch(ViewGroup.java:572) at android.view.ViewGroup.focusSearch(ViewGroup.java:572) at android.view.ViewGroup.focusSearch(ViewGroup.java:572) at android.view.ViewGroup.focusSearch(ViewGroup.java:572) at android.view.ViewGroup.focusSearch(ViewGroup.java:572) at android.view.View.focusSearch(View.java:4192) at android.widget.TextView.onCreateInputConnection(TextView.java:4936) at android.view.inputmethod.InputMethodManager.startInputInner(InputMethodManager.java:964) at android.view.inputmethod.InputMethodManager.restartInput(InputMethodManager.java:919) &lt;/code&gt; </code></pre> <p>Any idea? cheers. thanks a lot.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload