I am essentially trying to set the digits value of an EditText programmatically. So far I have:
weightInput.setInputType(InputType.TYPE_CLASS_PHONE);
weightInput.setKeyListener(DigitsKeyListener.getInstance());
Which is fine, but I also want to be able to include a decimal place (.). Any ideas?
For IP address input ( Multiple dots and numbers )
try
Try this:
Returns a DigitsKeyListener that accepts the digits 0 through 9, plus the minus sign (only at the beginning) and/or decimal point (only one per field) if specified.
This solve the problem about the many '.' in EditText
Use
InputType.TYPE_NUMBER_FLAG_DECIMAL
.Also see: Input Types.
Try this:
From Code:
But, it allows the user to include several "." See JoeyRA's answer for real numbers.