List drop down error

Hello

I create a drop-down list of cities.

but when I select an operation occurs according to the first entry in the list

I want to select a city from the drop-down list and click the next button to send the city selected to the next screen

Please take a look at my code and correct me

Thank you

Afonso

Code:

Choice of String() = {'New Delhi', 'New York', 'London'};
int iSetTo = 0;
OCF ObjectChoiceField = new ObjectChoiceField ("Select City", choice);     iSetTo);
ocf.setChangeListener (this);
CT = ocf.getSelectedIndex ();
System.out.println ("@ City:" + ct + ":" + ocf.getChoice (ct));
        
        
Add (new SeparatorField());
        
btnNextScreen = new ButtonField ("Next", ButtonField.CONSUME_CLICK |) ButtonField.FIELD_VCENTER);
btnNextScreen.setChangeListener (this);
        
        
This.Add (OCF);
This.Add (btnNextScreen);

----

----

-----

' Public Sub fieldChanged (field field, int context) {}
If (field is btnNextScreen)
{
-----

------

}

Look at this

String choices[] = {"New Delhi","New York","London"};

ObjectChoiceField ocf = new ObjectChoiceField("Select City",choices);             ocf.setChangeListener(this);        add(ocf);        System.out.println("@@@@@@@ City ::: "+ct+" ::: "+ocf.getChoice(ct));

        add(new SeparatorField());

        btnNextScreen = new ButtonField("Next", ButtonField.CONSUME_CLICK|ButtonField.FIELD_VCENTER);        btnNextScreen.setChangeListener(this);

        this.add(ocf);        this.add(btnNextScreen);

//
fieldChanged Method
public void fieldChanged(Field field, int context) {
        if( field ==  btnNextScreen)
        {
            ct = ocf.getSelectedIndex();
            String str = ocf.getChoice(ct);
            UiApplication.getUiApplication().pushScreen(anotherscreen(str));
        }

Do not hesitate to ask if you have any doubts.

------------------------------------------------------------------------------------
Kudo press to say thank you to the developer.
Also, press accept it as a button when you got the Solution.

Tags: BlackBerry Developers

Similar Questions

  • Problem of not seeing list drop-down connection to the wireless network when checking connections network - pc windows 7.

    Problem of not seeing list drop-down connection to the wireless network when checking connections network - pc windows 7.

    I just installed a Belkin modem-router - which went well. Can I connect WiFi gadgets etc. I can also connect to the internet via a network cable to my pc. I also installed a belkin usb wireless adapter and in Device Manager, says it is enabled and works.

    My problem is, I have no way of choice get a WiFi PC to display in the list (from the notification area) and cannot get the pc to give me options to create a wi - fi connection. The more I get to try to do that is "unexpected error"!

    If someone could help on this - I would be very grateful

    Good news - update of my ongoing saga with this Belkin modem/router.

    Got the pc to see wi - fi now. It turned out to be the Zone Alarm! As the router has a firewall, I uninstalled Zone Alarm completely. Also, I went into the properties of belkin usb and checked it was the most recent drivers, it does not so I installed them.

    So far so good

    Thanks for the help

    TREV Smith

  • ADD ITEMS TO THE LIST DROP-DOWN LIST TO A TEXT FIELD (USER ENTERS THE ITEM) AND ALSO RELATED TO VALUE

    Untitled.jpg

    I have WANTED to ADD of ELEMENTS from the list drop-DOWN OF THE AREA of TEXT (the ELEMENT NAME) WHERE the USER BETWEEN of THE DESCRIPTION of POINT

    AND RELATED value SHOULD ALSO BE ADDED to THE SAME ELEMENT.

    LIKEWISE REMOVE ITEMS IN THE DROP-DOWN LIST

    PLEASE GIVE SHAPE TO SAMPLE OR JAVASCRIPT FOR THE ABOVE SCENARIO...

    INDEED USEFUL FOR MY PROJECT PLEASE SEND PDF FORM

    Hi Praveen,

    You can add items to the list in a specific order, which would be to load the elements in an array, sorting and then load in the dropdown list drop-down list.  This would be in the click event of the button Add.

    Create a table to hold all the list items, table drop-down list contains objects with a property 'displayItem' and 'value '.

    dropDownItems var = [];

    Add the new

    dropDownItems.push ({displayItem: ItemName.rawValue, value: BoundValue.rawValue});

    Add existing ones

    for (var i = 0; i)< dropdownlist1.length;="">

    {

    dropDownItems.push ({displayItem: DropDownList1.getDisplayItem (i), value: DropDownList1.getSaveItem (i)})

    }

    Sort by ascending order of displayed text

    () dropDownItems.sort

    function (a, b)

    {

    If (a.displayItem< b.displayitem)="" return="">

    If (a.displayItem > b.displayItem) return 1;

    return 0;

    });

    clear all items

    DropDownList1.clearItems ();

    load the sorted items

    for (var i = 0; i)< dropdownitems.length;="">

    {

    var dropDownItem = [i] dropDownItems;

    DropDownList1.addItem (dropDownItem.displayItem, dropDownItem.value);

    }

    clear the fields of the source

    ItemName.rawValue = null;

    BoundValue.rawValue = null;

    I added a button 'Add' sorted in my sample https://workspaces.acrobat.com/?d=OwysfJa-Q3HhPtFlgRb62g

    Concerning

    Bruce

  • Show/hide multiple fields on list drop-down choice to help if else

    Goal is to display or hide the three fields according to a choice of menu drop-down. If show X, hide if Y.

    How a syntax on line error 6 when adding to the trigger mouse-to the top of the field drop-down list.

    Are several actions allowed for each if condition?

    if(event.target.value = "Yes")
      getField("Top_inches").display = display.visible;
      getField("Top_numerator").display = display.visible;
      getField("Top_denominator").display = display.visible;
    else
      getField("Top_inches").display = display.hidden;
      getField("Top_numerator").display = display.hidden;
      getField("Top_denominator").display = display.hidden;
    

    You have at least two syntax errors. The first is that you used the wrong operator for comparison. 'Is', not '=' (this is the value assignment operator).

    The second is that you did not put blocks of code inside the curly braces.

    If your code should be:

    if (event.target.value == "Yes") {
        this.getField("Top_inches").display = display.visible;
        this.getField("Top_numerator").display = display.visible;
        this.getField("Top_denominator").display = display.visible;
    } else {
        this.getField("Top_inches").display = display.hidden;
        this.getField("Top_numerator").display = display.hidden;
        this.getField("Top_denominator").display = display.hidden;
    }
    
  • List drop-down connection of AMT

    Using SQL Developer 4.0.1.14 - but I have seen this in other versions.  When I create a new connection or modify an existing one with Connection Type TNS and the drop-down list for network Alias, sometimes I see more than one alias with the same name.  There is only one entry with that name in my TNSNAMES file. ORA file.  I have only a single file, TNSNAMES. ORA file and is referenced by the TNS_ADMIN environment variable.

    Even more bizarre, sometimes by selecting one of these pseudonymous works, but one other will give me an error such as ORA-01034 or TNS.

    But again - can no problem, someone explain what is happening here?

    Prob b/c, you have several tns files * this directory - we read in more than a simple tnsnames.ora. You have all backups of this file?

  • How Pre-select value in list drop-down auto

    Hello

    I have an automatically populated drop-down list, and I'm trying to show with a value selected (in example 5). I didn't know where to start, so I changed the code in Dreamweaver for "set value equal to" leave the function of dynamic list. List views, but the default value 0. What Miss me?

    <? PHP
    echo "< select name ="firstnumber"id = ' number' > ';"
    for ($j = 0; $j < 11; $j += 1)
    {
    echo "< option value =------' $j\ ' <? PHP if (!) ((strcmp (\"$j\",5)))) {echo \"selected=\"selected\"\ ';}? "> $j < / option > \n";
    }
    echo "< / select >.
    ? >

    Thank you

    Tim

    The problem is that you have nested PHP tags inside a PHP block. You can't do that. In fact, it is surprising that the code works at all. Normally, nesting tags PHP inside a block of PHP code will cause a syntax error.

    In addition, your code is very hard to read because of the way you use double quotes all the time. It is best to use single quotes for strings, except when you need display the value of a variable inside a string. You can also nest the double quotes inside a string in single quotes and vice versa, for code that is easier to read without the backslashes.

    That's how I rewrote your code:

    
    
  • Why firefox changed look. Where is my list drop down firefox?

    Firefox has started this morning... received the verification... then ff addons message came. The problem is that it has changed. The firefox drop-down list in the upper left disappeared, tabs funky look and menu is a uglyfest of dimension 1.
    How can I go back to the previous appearance. I turned off automatically updated because it seems that mozilla is not reliable... but I want the old look back

    d. second do not know why you are taking this personally. Didn't even know you so don't be angry at you.

    Sorry, I use cuts to write my answers since writing the same thing 15 times a day can be frustrating. It happens that I don't remember to delete the part "so to get angry with me will do nothing good."

    Please let me know on what you decide to do.

    I think personally the side user and not the title of moderator, envision at least to use another browser, because privacy and security cannot be overlooked.

  • "Data dashboard" version 2.0 list drop-down list seen only "one, two, etc.» Instead of the text Enum

    I am currently using the new data on an iPad dashboard 1. I'm coding in suite developer Labview 2012. I found that switches work very well when it is associated with a shared variable. I finally managed to get the drop-down list to control a shared variable of data type typedef/enum. This control very well within the Labview program, but on the dashboard of data drop-down list shows only the "One" "two" etc... instead of the text 'This' Enum 'As' 'Other' I can write back to the dashboard with a text conversion of the enum to the dashboard and place it in a display of string over the fall down. While this gives the operator a display of the current Typedef/enum, it is not very intuitive. They must select 'One' to view 'This' "two to display 'Than' etc...

    How can I get the dashboard of data drop-down list control to display the text of the enum instead of "one" "two" etc?

    I think the point was that your question belongs to this other forum, not the forum of LabVIEW.

    (I'll ask the moderator to move this thread i).

  • programmlly list drop-down ring or combobox

    Hi all

    I want to programlly the ring or the combobox, as click on the ring or combobox then get a drop-down list, how do? .. .thanks

    See also here, where I asked the same question.

  • updated list drop down menu by typing item

    Hi guys,.

    I create a drop-down list by using enum. The drop down menu may have about 1000 + points. Is that possible the menu drop down to update the selection, I want while typing the word?

    The enumeration so that the controls of the ring won't let you type in when the vi is in run mode. A combo box can do what you expect

  • Select Excel list drop-down element in LabVIEW

    Hi all

    I need to open an excel workbook and send data to a particular LabVIEW worksheet

    In itself, it is simple, BUT the spreadsheet has also a few combo boxes I need to autmate a choice on.

    is anyway to do this? The spreadsheet vb code is password so I can't create macros additional within which to do, I need to do all of the Labview

    Can't seem to find a way to reference drop-down lists, the most appreciated any help woul dbe

    Thank you

    Mike

    According to the Excel 2010 developer reference if you set the value of the linked cell the combo box will be that he has the correct value for this cell value so if you know what value you want to set, and which cells are linked you just.

    If this does not work for you all the controls are objects of form so you can use the Shapes on the worksheet collection to find and manipulate.

  • Lower half of the screen of list drop-down settings of notification/unresponsive

    This is particularly visible in the drop-down list of parameters Lollipop (menu you get when you drag to the bottom of the top of the screen twice or with two fingers), but also occurs when I have many notifications.

    All the icons on the two lower lines (lamp pocket, flight Mode, Portrait, Mobile Hotspot, data & screen Cast) almost always do nothing when I type directly on them. It's as if the tactile area of the icon is very small, so 95% of the time that I can't trigger the action. I've found that I can trigger the icons on the 2nd line by typing slightly above them, although it is still dark.

    Although I have many notifications, I struggle to slip far lower levels and pressing 'Clear all' is very difficult.

    I can post a video showing so useful button.

    Edit: turn the unit off and on again the fixed, at least temporariliy. Will post a vid if it happens again - this is a very annoying bug when it arrives!

    @amwoo

    I have not been able to replicate this, what would you say if you can start in safe mode and try again.

    http://talk.sonymobile.com/T5/FAQ/How-to-boot-your-phone-into-safe-mode/m-p/348008#U348008

  • Send list drop-down page or a link in the page not activated

    By clicking on the Page button and access the drop-down list the link send the list and send the page options are not enabled. I can add to the toolbar, but why they are not activated as they once used to be?

    By clicking on the Page button and access the drop-down list the link send the list and send the page options are not enabled. I can add to the toolbar, but why they are not activated as they once used to be?

    Just in case, please check if Internet Explorer has all its flaws.

    t-4-2

  • List drop-down events

    Can someone point me to information on events from the drop-down list? I want to deal with when the selection in the drop-down list has changed.

    myDropDown.addEventListener (Event.SELECT, myFunction, true, 0, true);

    The foregoing is not to do the trick.  I see MouseEvents.CLICK events if I change the event above.

    Thanks in advance.

    Hey kaptuafj,

    According to the API reference page:

    http://www.BlackBerry.com/developers/docs/airapi/1.0.0/QNX/UI/listclasses/dropdown.html

    the event that should be listened to is Event.SELECT. I'll write a program and run it to confirm.

    Edit: Just run the program and it works very well. Event is triggered and captured. Just make sure that your listener function looks something like that with the event in parentheses:

    public function myFunction(e:Event):void
    

    Edit #2: Hey just used your line:

    myDropDown.addEventListener(Event.SELECT, myFunction, true, 0, true);
    

    and it does not. If you set the argument usecapture false it will start working. unless you have a specific reason to be true, usually this option is set to false by default. unless you need all these arguments usually just using this line also does the trick:

    myDropDown.addEventListener(Event.SELECT, myFunction);
    

    Here are the details for the argument usecapture if you need a deeper look:

    http://www.ActionScript.org/resources/articles/860/3/understanding-the-AS3-event-flow/page3.html

    Let me know if it works!

  • WebView: cannot scroll through long lists drop-down/select

    I added webview standard, but are unable to scroll through long lists on drop-down lists (html select). It shows just the best selections and im unable to scroll in the list to select something lower.

    Someone else has webview with selection lists for a long time who have this problem, or do NOT have this problem?

    the latest version of the OS fixed this! So update your OS to dev for the device and you should be ok!

Maybe you are looking for