Reputation: 818
I want to set an automatic thousand separator to my edittext. I did it with an textwatcher. In
public void afterTextChanged(Editable s)
i save the current value of my edittext, format it with
@Override
public void afterTextChanged(Editable s) {
InputField.this.removeTextChangedListener(this);
double tmp = getDoubleValue();
s.clear();
s.append(DecimalFormat.getInstance(Locale.GERMAN).format(tmp));
InputField.this.addTextChangedListener(this);
}
});
But the Keyboard from my Galaxy Tab doesn't care If I clear the editable. It keeps the current input and fills the edittext with the complete number. A short example:
I type "1", the keyboard inserts "1", the edittext shows "1".
I type "2", the keyboard inserts "12", the edittext shows "112"
I type "3", the keyboard inserts "123", the edittext shows "112.123"
I press the delete button, the keyboard inserts "12", the edittext shows "11.212.312"
I press the delete button again, the keyboard inserts "1", the edittext shows "112.123.121"
My question is:
how can I disable this keyboardfeature?
or how can I clean this keyboard "cache"?
If I use inputtype "numberDecimal", it works but I can't use points as thousand separators(but it is needed in germany), because they will be interpreted as decimal mark and there can only be one.
Upvotes: 2
Views: 2428
Reputation: 7745
I am not sure if you can clean the cache, but how about disabling the suggestion bar.. you can do that programatically:
YourEditText.setInputType(YourEditText.getInputType()
| EditorInfo.TYPE_TEXT_FLAG_NO_SUGGESTIONS
| EditorInfo.TYPE_TEXT_VARIATION_FILTER);
or you can deactivate in your EditText
XML tag.. you can set:
<EditText>
android:inputType="textFilter
.... />
you can use this value too but unfortunately it doesn't work in all devices specially HTC
android:inputType="textNoSuggestions"
Edit
Sometimes it doesn't work because it's up to the implementation of the keyboard to do the right thing including the Flags.. However, everything has a workaround can you try the following code in XML:
android:inputType="textNoSuggestions|textVisiblePassword"
or in Java:
yourEditText.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
and give me a feedback if it worked or not..
Upvotes: 3