×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Feb 2012
    Posts
    14

    Post setting value of TextField is giving null

    Hello
    I m making a j2me app which needs filling form from RMS at runtime. Everything is running alright but setting value of TextField using setString() method is giving null pointer exception.
    Please guide me where i m wrong or is there other way to implement this functionality.
    I m usind javax.microedition.lcdui.TextField; api

  2. #2
    Nokia Developer Moderator
    Join Date
    Dec 2011
    Posts
    174

    Re: setting value of TextField is giving null

    Hi sanjaygoyaljpr,

    The setString(String text) method could give a nullpointer exception if your TextField is null and not initilized. Other exceptions may come if the text is illegal for the current constrait or the text would exceed the maximum capacity. It might be easier to find the problem if you could provide a code snippet how you are implementing the TextField.

    Here's a wiki example of using a TextField: http://www.developer.nokia.com/Community/Wiki/Textfield

    -tiviinik

  3. #3
    Registered User
    Join Date
    Feb 2012
    Posts
    14

    Re: setting value of TextField is giving null

    Thank you very much...My code snippet is like..
    TextField moblie = new TextField("First Name", "", 15, TextField.Numeric);
    String mob = "1234567890";
    name.setString(mob); //this line is giving NullPointerException

  4. #4
    Nokia Developer Moderator
    Join Date
    Dec 2011
    Posts
    174

    Re: setting value of TextField is giving null

    If you want to set the text of the TextField moblie it should be

    Code:
    TextField moblie = new TextField("First Name", "", 15, TextField.Numeric);
    String mob = "1234567890";
    
    moblie.setString(mob);
    -tiviinik

  5. #5
    Registered User
    Join Date
    Feb 2012
    Posts
    14

    Re: setting value of TextField is giving null

    hi tiviinik....
    In my last post, there was writing mistake.
    TextField moblie = new TextField("First Name", "", 15, TextField.Numeric);
    String mob = "1234567890";
    mobile.setString(mob);
    This code is also giving NullPointerException.But i hv found solution by changing TextField.numeric to TextField.Phonebook.

  6. #6
    Nokia Developer Moderator
    Join Date
    Dec 2011
    Posts
    174

    Re: setting value of TextField is giving null

    I see no reasons why the below code snippet should not work with the TextField.NUMERIC constrait. I also tested it with the SDK 1.1 and had no problems. Which device/emulator are you using and does this exception occur on device or emulator or both?

    Code:
    TextField moblie = new TextField("First Name", "", 15, TextField.NUMERIC);
    String mob = "1234567890";
    moblie.setString(mob);
    -tiviinik

Similar Threads

  1. Replies: 0
    Last Post: 2010-06-02, 08:37
  2. Setting focus and tabbimg between TextField objects
    By jeffez in forum Mobile Java General
    Replies: 3
    Last Post: 2010-04-10, 19:30
  3. Leaking memory when setting SVGMenu to null
    By GuusDavidson in forum Mobile Java Media (Graphics & Sounds)
    Replies: 0
    Last Post: 2008-07-15, 06:12
  4. Zero initialisation and setting pointers to NULL in destructor
    By Sorcery-ltd in forum Tools and SDK Feedback (Closed)
    Replies: 7
    Last Post: 2007-10-27, 21:07
  5. Setting a TextBox / TextField to use T9 dictionary as default???
    By newmania in forum Mobile Java General
    Replies: 1
    Last Post: 2003-04-15, 07:11

Posting Permissions

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