I am developing a Point Of Sales app.
So I would like to let user to enter the purchase amount
Let's say User input 100000
but I want it to automatically show up 100,000
. and 1000000
become 1,000,000
The second problem is that, I don't want user to be able to input .
themselves.
Third problem is that since this is money, we can't let user to enter 0 in the beginning.
Any ideas?
So far I can only come up with inputType=numberDecimal
which is not really helpful.
Thank you very much
P.S.: I do not need any decimal places
For your first problem follow this link Thousand separator
For your second problem add this to your editext
android:digits="0123456789"
android:inputType="numberDecimal"
And for your third problem you have to use TextWatcher like this
editText1.addTextChangedListener(new TextWatcher(){
public void onTextChanged(CharSequence s, int start, int before, int count)
{
if (editText1.getText().toString().matches("^0") )
{
// Not allowed
Toast.makeText(context, "not allowed", Toast.LENGTH_LONG).show();
editText1.setText("");
}
}
@Override
public void afterTextChanged(Editable arg0) { }
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
});