×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Apr 2009
    Posts
    40

    LWUIT TextField: Not more than 1 "POINT-Character"

    Hi,

    I am creating an app with LWUIT. I have several TextFields with DECIMAL Format. Allowed are only Numbers (0...9) and a separator ".". Can I handle the Input, so that the separator "." can only be input one time? I use the virtual Keyboard (but on phones with number-pad it can also be input by hardware-keypad).

    I want to avoid an input, that has more than one separator, because then the app wil throw a numberformatexception.

  2. #2
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    3,085

    Re: LWUIT TextField: Not more than 1 "POINT-Character"

    Quote Originally Posted by carsamba55 View Post
    Hi,

    I am creating an app with LWUIT. I have several TextFields with DECIMAL Format. Allowed are only Numbers (0...9) and a separator ".". Can I handle the Input, so that the separator "." can only be input one time? I use the virtual Keyboard (but on phones with number-pad it can also be input by hardware-keypad).

    I want to avoid an input, that has more than one separator, because then the app wil throw a numberformatexception.
    Put a dataChange Listener() on your textField and validate every user input and do not update the txtfield if dot is pressed again.
    thanks,
    ~Amitabh
    (Champion of the Month -Aug'13)
    Follow me on my blog for Innovative Mobile Apps

  3. #3
    Registered User
    Join Date
    Apr 2009
    Posts
    40

    Re: LWUIT TextField: Not more than 1 "POINT-Character"

    I understand what you mean, but the problem is, when I make an input, the sign is automatically pasted in the textfield on the screen, and in the textfield of the virtual keyboard. I dont know how to make something like this:

    Code:
    myTextfield.addDataChangeListener(new DataChangedListener() {
                public void dataChanged(int i, int i1) {
    
                    DO not write in the textfield until:
                          IF theres already a "." in the textfield:
                                 Do nothing
                         ELSE
                                write in the textfield
    
                }
            });
    I can delete all "." which are pasted after the first ".", but I want to do it while I am writing, so I want to stop pasting in the 2 textfields, before I checked the chars.

Similar Threads

  1. Replies: 0
    Last Post: 2010-08-09, 21:00
  2. avoiding "select access point" message"
    By oyuky in forum Symbian
    Replies: 4
    Last Post: 2008-05-30, 14:32
  3. Nokia 7210 SDK Bug: TextField.NUMERIC allows "w" and "p"
    By vizionari in forum Mobile Java Tools & SDKs
    Replies: 1
    Last Post: 2003-05-12, 14:33
  4. Replies: 2
    Last Post: 2002-05-15, 11:58

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×