×

Discussion Board

Results 1 to 5 of 5
  1. #1
    Regular Contributor
    Join Date
    Jun 2009
    Posts
    179

    Exclamation getting value from textfield

    At the time of press of ok button in the main menu i have created textfield in form called

    "RequestIndent" like this ..

    TextField text = new TextField(menu_item[i], null, 32, TextField.ANY);
    RequestIndent.append(text);

    now in form "RequestIndent" i have to fetch all the values put in all the textfields , but i am

    not able to do so , if i would be able to create dynamic objects some thing like this my problem

    would have been solved

    TextField text[i] = new TextField(menu_item[i], null, 32, TextField.ANY);
    RequestIndent.append(text);

    i would have fetched values something like this

    String value = text[i].getString();

    but jave does not supports creating objects dynamically , hence i am not able to get the values

    in all the textfields , kindly help to solve this problem

    thanks and regards
    Arunesh

  2. #2
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: getting value from textfield

    Quote Originally Posted by Arunesh View Post
    if i would be able to create dynamic objects some thing like this my problem

    would have been solved

    TextField text[i] = new TextField(menu_item[i], null, 32, TextField.ANY);
    RequestIndent.append(text);

    i would have fetched values something like this

    String value = text[i].getString();

    but jave does not supports creating objects dynamically
    Yes it does. Java only supports dynamic object creation. You're creating them dynamically either way. There's nothing to stop you holding the references to the objects in an array.

    Graham.

  3. #3
    Regular Contributor
    Join Date
    Sep 2008
    Location
    Ahmedabad
    Posts
    254

    Re: getting value from textfield

    Hi,

    You can definitely fetch the values from TextFields on the button pressed event. Can you put in the code and where you are getting the problem? You can have an array of TextFields and initialize them when you want or on particular button press event.
    Sunil
    Mobile Application Developer

  4. #4
    Regular Contributor
    Join Date
    Jun 2009
    Posts
    179

    Exclamation Re: getting value from textfield

    when i am writing this code it is working fine

    for(int i = 1;i<=menu_item.length-1;i++)
    {

    System.out.println("menu appended at "+i+" place");
    /*text[i] = new TextField(menu_item[i], null, 32, TextField.ANY);
    RequestIndent.append(text[i]);*/

    TextField tex = new TextField(menu_item[i], null, 32, TextField.ANY);
    RequestIndent.append(tex);


    }
    but when i am writing this code i am getting null pointer exception

    for(int i = 1;i<=menu_item.length-1;i++)
    {

    System.out.println("menu appended at "+i+" place");
    text[i] = new TextField(menu_item[i], null, 32, TextField.ANY);
    RequestIndent.append(text[i]);



    }

    while this has been defined at the start of application like this

    TextField[] text;

    pls help me solve the problem

    thanks and regards
    Arunesh

  5. #5
    Super Contributor
    Join Date
    Jun 2003
    Location
    Cheshire, UK
    Posts
    7,395

    Re: getting value from textfield

    If you want an array, you need to create one.

    Code:
    TextField[] text = new TextField[ARRAY_SIZE];
    You might want to do some reading to get up to speed on basic Java.

    Graham.

Similar Threads

  1. Replies: 1
    Last Post: 2010-03-07, 15:32
  2. TextField problem
    By thanhvinh0906 in forum Mobile Java General
    Replies: 3
    Last Post: 2009-10-08, 19:24
  3. Problem of TextField key hooking...
    By raselbd in forum Mobile Java General
    Replies: 3
    Last Post: 2008-09-02, 08:21
  4. TextField in DECIMAL: Compatibility problems with some phones?!?
    By D0X-Dr in forum Mobile Java Tools & SDKs
    Replies: 12
    Last Post: 2008-01-11, 10:08
  5. Cannot use textField after delete and insert in Form
    By andretr in forum Mobile Java Tools & SDKs
    Replies: 1
    Last Post: 2004-08-03, 13:33

Posting Permissions

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