开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜