I want to money input box without dollar symbol. There is a code which works fine with dollars
private int price = 0;
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
if(!s.toString().matches("^\\$(\\d{1,3}(\\,\\d{3})*|(\\d+))(\\.\\d{2})?")) {
String userInput = "" + s.toString().replaceAll("[^\\d]", "");
if (userInput.length() > 2) {
Float in = Float.parseFloat(userInput);
price = Math.round(in); // just to get an Integer
//float percen = in/100;
String first, last;
first = userInput.substring(0, userInput.length() - 2);
last = userInput.substring(userInput.length() - 2);
inputAmount.setText("$" + first + "." + last);
Log.e(FragTutar.class.toString(), "first: " + first + " last:" + last);
inputAmount.setSelection(inputAmount.getText().length());
}
}}
});
i tried all ways and i couldn't remove $ sysmbol. How can i remove on this code?