Configure android EditText to allow decimals and negatives

We can use,

edit_text.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_SIGNED);

if we need to use programmatically..


You are just missing this in your EditText,

android:inputType="numberDecimal|numberSigned"

See this link may be it's help you http://developer.android.com/resources/articles/creating-input-method.html

and The possible values for the android:inputtype are:

•none
•text
•textCapCharacters
•textCapWords
•textCapSentences
•textAutoCorrect
•textAutoComplete
•textMultiLine
•textImeMultiLine
•textNoSuggestions
•textUri
•textEmailAddress
•textEmailSubject
•textShortMessage
•textLongMessage
•textPersonName
•textPostalAddress
•textPassword
•textVisiblePassword
•textWebEditText
•textFilter
•textPhonetic
•textWebEmailAddress
•textWebPassword
•number
•numberSigned
•numberDecimal
•numberPassword
•phone
•datetime
•date
•time