views:

14

answers:

1

Hi,

I created a BasicEditField in Blackberry and added a NumericTextFilter (set to REAL_DECIMAL). It does what I expect (allows negative and decimal). However, I want to allow one more character, that is 'e'. E.g. 1.234e5, which is equal to 1.234x10^5. Well, looking at my example, RIM should agree that '1.234e5' is a real decimal.

I just want to ask if anyone here has a suggestion on how I can allow 'e' here?

I believe 1.234e5 and even 1.234e-5 is parseable by Double.

Many thanks

EDIT: by the way, I am using Blackberry OS 5.0.

+1  A: 

I think you will need to implement your own subclass of TextFilter or NumericTextFilter if you want to support numbers in "scientific notation". According to the javadoc, NumericTextFilter only understands numbers consisting of decimal digits and (depending on the flags) a decimal point and/or leading minus sign.

Stephen C
Hi Stephen, I extended TextFilter and now able to specify which characters I want to support. [-0123456789.eE]. Working fine but I have a minor issue. The keypad is defaulted to character mode. If application runs on Storm, the keypad displays one character 'E' and have to alt in order to key in numeric characters. If I changed my class to extend the NumericTextFilter instead, it is locked to numbers which is what I want, but when I press 'E' on 'ABC' mode, it will key in '2' instead of 'E'. My class overrides convert(), and validate().
demotics2002
I am thinking of just using the TextFilter instead of NumericTextFilter as the parent class, but is there a way to programmatically set the keypad mode to Num Lock?
demotics2002
Sorry - I've no idea. Suggest you ask a new question.
Stephen C
Sure. Will try it also at blackberryforums.
demotics2002