I am not quite familiar in android please help. My problem is I want to remove a dot inside an EditText
. In my activity I have one EditText
which is set to inputType of numberDecimal
. Now when I change it to number
the dot in the keypad disappear but in the higher android pf version it appears. By the way I am using android version 2.3.6.
What I did here is set the inputType to decimal and trap the decimal point whenever the user inputted it.
Here's my code:
myEditText.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
// TODO Auto-generated method stub
String str = s.toString();
if(s.length() > 0 && s.toString().charAt(s.length() - 1) == '.')
{
showMessage("Decimal numbers is not allowed");
CharSequence text = s.subSequence(0, s.length()-1);
myEditText.setText(text);
}
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
// TODO Auto-generated method stub
}
@Override
public void afterTextChanged(Editable s) {
// TODO Auto-generated method stub
}
});
Perfectly it removes the dot but the problem right now is the pointer is moving backward and start from the beginning again.
My question how can make the pointer go to front? instead of starting again.