implement Numerical Edit Text in Android
I am trying to implement getting contents of edit text as a number as exemplified in iOS. The intention is for the user to enter only numerical values.
I am wondering if there is a similar implementation in Android. Can this be done??
I would appreciate some excellent advice. Thanks.
You can use the android:numeric
for this like:
<EditText android:text="435.569"
android:id="@+id/EditText01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:numeric="integer|decimal" />
to do this dynamically just try something like :EditText.setInputType(InputType.TYPE_CLASS_NUMBER);
Good luck Arkde
The EditText
-widget has the inputType
-attribute, which can be used to determine what type of input the user should make.
There is also the corresponding method setRawInputType()
to set it programmily.
精彩评论