Novice: Restrict data entry type

Put your problem here if it does not fit any of the other categories.

Novice: Restrict data entry type

Postby iaindownie » Wed Dec 02, 2009 10:33 am

Hi,
I have a few fields in a standalone application that I want to collect numbers only (e.g. 42.198) from. What's the best way to stop folk entering letters etc.? Easy in JavaScript, but I've never done it in a Android application before.
Thanks
Iain
User avatar
iaindownie
Experienced Developer
Experienced Developer
 
Posts: 84
Joined: Mon Dec 29, 2008 4:08 pm
Location: Thetford, Norfolk, UK

Top

Postby appforce » Wed Dec 02, 2009 4:48 pm

appforce
Experienced Developer
Experienced Developer
 
Posts: 60
Joined: Mon Nov 23, 2009 8:28 pm

Postby iaindownie » Thu Dec 03, 2009 10:13 am

Thanks. I'll have a look, although I'm not quite sure how to implement it.
Iain
User avatar
iaindownie
Experienced Developer
Experienced Developer
 
Posts: 84
Joined: Mon Dec 29, 2008 4:08 pm
Location: Thetford, Norfolk, UK

Postby appforce » Thu Dec 03, 2009 10:19 am

Hi,

You can put this in where you define the EditText in your XML layout:

android:inputType="numberDecimal"

This will make it accept only numbers.


Android developers
appforce
Experienced Developer
Experienced Developer
 
Posts: 60
Joined: Mon Nov 23, 2009 8:28 pm

Postby iaindownie » Thu Dec 03, 2009 11:51 am

Brilliant, works a treat, and so simple.
Much appreciated....
Iain
User avatar
iaindownie
Experienced Developer
Experienced Developer
 
Posts: 84
Joined: Mon Dec 29, 2008 4:08 pm
Location: Thetford, Norfolk, UK

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: Exabot [Bot], Yahoo [Bot] and 16 guests