×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 21
  1. #1
    Regular Contributor
    Join Date
    Mar 2010
    Location
    Bangalore
    Posts
    50

    Post String Selection issues

    Hi,

    I am writing a piece of code wherein i am facing certain issues.Kindly guide me.

    My idea/plan:
    To search for certain names/keywords and retrieve information from a particular database. Display the same on the mobile screen.

    What I've done so far:
    As of now , I've created a Form , added a TextField and StringItem (to match the case that i search).

    I am able to search and retrieve information from the database. I've displayed the search results in a List so that i can use the "getSelectedIndex" and "isSelected" commands to select the obtained results. After selecting these results , i would want to provide more detail about the selected option.

    Issues am facing:
    I am unable to select those strings in the List and display further information about the selected data.

    Firstly , am on the right path ?
    Is this possible (selecting strings inside list) ?

    Kindly throw some light into this

    Thanks
    - Ashwin

  2. #2
    Registered User
    Join Date
    Oct 2009
    Location
    Noida
    Posts
    941

    Re: String Selection issues

    Issues am facing:
    I am unable to select those strings in the List and display further information about the selected data.

    Firstly , am on the right path ?
    Is this possible (selecting strings inside list) ?
    You can use list.getString(list.getSelectedIndex()); to get the selected string from List.

    Yes you are on correct path, now you need to make a new search for the selected String and get its details from database or network.

    thanks,
    Ekta

  3. #3
    Registered User
    Join Date
    Dec 2009
    Location
    Bangalore/Mysore, Karnataka, India.
    Posts
    43

    Re: String Selection issues

    Quote Originally Posted by itzashwin View Post
    I am unable to select those strings in the List and display further information about the selected data.
    Are you able to display the list in the same form?
    Can you please give more info on how you are accessing the List.

    Quote Originally Posted by itzashwin View Post
    Firstly , am on the right path ?
    I think you are in the right path.

    Quote Originally Posted by itzashwin View Post
    Is this possible (selecting strings inside list) ?
    - Ashwin
    AFAIK, Yes it is possible.

    -Roopesh.

  4. #4
    Regular Contributor
    Join Date
    Mar 2010
    Location
    Bangalore
    Posts
    50

    Re: String Selection issues

    Hi Ekta,

    Thanks very much for the quick response.

    I need something like this, say for example : I have two names - Ashwin and Ashish

    As you can see , both names have the first 3 letters common - "Ash"

    now i need to put something like an if statement saying "if the string contains or starts with so and so" i need to display the result accordingly.

    PS : I have already made a form to display the details of Ashwin and Ashish. So , i can directly call the function Ashwin() or Ashish() after the if statement.

    Hope you are getting what i intend to do

    - Ashwin

  5. #5
    Regular Contributor
    Join Date
    Mar 2010
    Location
    Bangalore
    Posts
    50

    Re: String Selection issues

    Hi Roopesh,

    Thanks very much for the quick response.

    ------------------------------------------------------------------
    Are you able to display the list in the same form?
    Can you please give more info on how you are accessing the List.
    ------------------------------------------------------------------

    After i search from the database, i've made a list to display those results. Now i need to select those strings from this list and display more detail about the selected option. String selection is where i am facing a problem.

    Also , Please refer my reply to Ekta , i've provided more details.

    Hope you are getting what i intend to do. Please let me know if you are not.

    - Ashwin

  6. #6
    Registered User
    Join Date
    Dec 2009
    Location
    Bangalore/Mysore, Karnataka, India.
    Posts
    43

    Re: String Selection issues

    Hi Ashwin,

    Now this is what I understood.
    *)If u type 'ash' in the Textbox, a List gets appended containing the names Ashwin and Ashish.
    *)Now if I select (by clicking Fire key when the corresponding name is focussed) one of those names then another form with corresponding info should get displayed. But this is not happening.

    Am I right???

    -Roopesh
    Last edited by roopesh.kumar; 2010-05-13 at 08:10. Reason: grammatical mistake.

  7. #7
    Regular Contributor
    Join Date
    Mar 2010
    Location
    Bangalore
    Posts
    50

    Re: String Selection issues

    Hi Roopesh,

    SPOT ON !! , Kindly help me with the string selection part , so that when i select these options , i can display the necessary info.

    Thanks
    - Ashwin

  8. #8
    Regular Contributor
    Join Date
    Mar 2010
    Location
    Bangalore
    Posts
    50

    Re: String Selection issues

    Just to make things easier , some more info's I would like to share pertaining to my problem.


    private List list ;
    private Command command;
    String[] names = { Ashwin , Ashish , Nokia , Motorola , Samsung , Sony , LG };

    {

    /*
    .
    .
    .Body of my code
    .
    .
    */

    if (command = list.SELECT_COMMAND)
    {

    Need the string selection code to fit in here

    }
    }
    Last edited by itzashwin; 2010-05-13 at 08:36. Reason: edited the code

  9. #9
    Registered User
    Join Date
    Dec 2009
    Location
    Bangalore/Mysore, Karnataka, India.
    Posts
    43

    Re: String Selection issues

    Hi Ashwin,

    Can you please tell me why you are using StingItem??
    I guess you are adding just two StringItems with labels 'Ashwin' and 'Ashish' into the Form. Is it??

    -Roopesh.

  10. #10
    Registered User
    Join Date
    Dec 2009
    Location
    Bangalore/Mysore, Karnataka, India.
    Posts
    43

    Re: String Selection issues

    Quote Originally Posted by itzashwin View Post

    if (command = list.SELECT_COMMAND)
    {

    Need the string selection code to fit in here

    }
    }
    If you are using the above code then, as suggested by Ekta this should work.
    list.getString(list.getSelectedIndex());

  11. #11
    Regular Contributor
    Join Date
    Mar 2010
    Location
    Bangalore
    Posts
    50

    Re: String Selection issues

    Hi Roopesh,

    Am using the StringItem for displaying in such a way that the obtained result cannot be edited. Moreover , its compatible with the Form.

    Now i need to put something like an if statement saying "if the string contains or starts with so and so" i need to display the result accordingly. Have a look at the code below , just a blind example ( has no meaning though )

    In my example,

    if (names.startsWith("Ash") || names.contains("win"))
    {
    Ashwin();
    }
    else if (names.startsWith("Ash") || names.contains("ish"))
    {
    Ashish();
    }


    It must be something like this, only then i can match up and provide the exact results from my database. Hope you understand.

    Thanks
    - Ashwin

  12. #12
    Registered User
    Join Date
    Dec 2009
    Location
    Bangalore/Mysore, Karnataka, India.
    Posts
    43

    Re: String Selection issues

    Quote Originally Posted by itzashwin View Post
    Am using the StringItem for displaying in such a way that the obtained result cannot be edited. Moreover , its compatible with the Form.
    Thats fine... But what are you displaying in it??? (Or what is the obtained result).

    BTW, try printing something inside the CommandListener and see if you are getting there. Like
    if (command = list.SELECT_COMMAND)
    {
    System.out.print("Coming inside CommandAction");
    //Need the string selection code to fit in here
    }

  13. #13
    Regular Contributor
    Join Date
    Mar 2010
    Location
    Bangalore
    Posts
    50

    Re: String Selection issues

    Hi Roopesh,

    All that works fine. The only issue is selecting a string and displaying details about it.

    Thanks
    -Ashwin

  14. #14
    Registered User
    Join Date
    Dec 2009
    Location
    Bangalore/Mysore, Karnataka, India.
    Posts
    43

    Re: String Selection issues

    Try this and tell me what happens.

    if (command = list.SELECT_COMMAND)
    {
    System.out.println("Selected ListItem is: "+ list.getString(list.getSelectedIndex()));
    //Need the string selection code to fit in here
    }

  15. #15
    Regular Contributor
    Join Date
    Mar 2010
    Location
    Bangalore
    Posts
    50

    Re: String Selection issues

    Hmm , this was what i had in the database.

    String[] names = { Ashwin , Ashish , Nokia , Motorola , Samsung , Sony , LG };

    I searched for Ash , i obtained the results

    Ashish
    Ashwin

    I selected Ashwin, i obtained the output:

    Selected List Item is: Ashwin

Similar Threads

  1. delete record
    By meghali3 in forum Mobile Java General
    Replies: 9
    Last Post: 2009-10-08, 19:29
  2. Problem with Sax Parser
    By pecmanuser in forum Mobile Java General
    Replies: 1
    Last Post: 2009-08-04, 10:20
  3. how to get sub string of a long string in j2me
    By mindIt in forum Mobile Java General
    Replies: 5
    Last Post: 2009-07-04, 10:05
  4. Application error
    By hiteshrawat in forum Mobile Java General
    Replies: 13
    Last Post: 2009-06-25, 14:26
  5. Replies: 8
    Last Post: 2008-03-05, 07:21

Posting Permissions

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