ChoiceField help

Hi here is my problem

I've created a subclass (DynamicObjectChoice) that extends ObjectChoiceField and created an another subclass (MyObjectChoiceListener) that extends FieldChangeListener.

In DynamicObjectChoice I crushed constructor and take an int parameter.

Then in my main class, I've created a DynamicObjectChoice and fill in a loop like this.

for (int i = 0; i < someInt; i++) { choiceFieldArray[i] = new DynamicObjectChoiceField(Label, choices, 0, i);
            MyObjectChoiceListener listener= new MyObjectChoiceListener();
            choiceFieldArray[i].setChangeListener(listener);
            add(choiceFieldArray[i]);}

and crushed fieldChange MyObjectChoiceListener with this method.

public void fieldChanged(Field field, int context) {
            System.out.println((DynamicObjectChoiceField)field).getLabel());
}

AND HE SAID CLASSCASTEXCEPTION! Why? im stuck here.  I have founfd that I have change

System.out.println((DynamicObjectChoiceField)field).getLabel());

TO

System.out.println((ChoiceField)field).getLabel());

It works but I need other methods that are available only on DynamicObjectChoiceField. Help, please!

I solved this problem, but I don't understand why I should use it. I think that the event 'clone' the field being passed at run time, and when you try to cast it giives you classcast exception. Solution was this:

((DynamicObjectChoiceField) field.getOriginal()).getLabel();

So in the hope that it helps someone else.

Tags: BlackBerry Developers

Similar Questions

  • How to recover data from the choicefield retained

    Hello

    How to recover data from the choicefield retained

    Thank you

    SujithRavindran

    getSelectedIndex method will help you.

  • ChoiceField

    Hello, I had a few problems by performing a ChoiceField correctly.  I want to have a Choicefield with just two options in there.  What would be the right way to do this?

    Thank you

    Scientist

    take an array of strings.

    [] Str As String = {"First", "Second"}

    Choicefield ObjectchoiceField = new ObjectchoiceField("",str);

    Add (choiceField);

    I hope this help you.

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

  • JVM error 104 on the torch please help.

    Hi all

    I developed an application for the 9500 series touch screen devices, I tested it on these devices and all is well with the Simulator and the real device.

    But when I load it the torch I get the JVM error 104 and I used throughout the app try/catch blocks, but I can catch the source of the error.

    I then tried to add the application on a device 9300 and everything works again. For some reason any app just does not the torch.

    The application starts fine, but when I select anything within the app it "breaks".

    Can someone please help with this problem. If there is anything that I can provide please let me know.

    -----------------------------------------------------------------------------------------------------------------------------------------------------------

    Thread [BTM__Bussiness_Trip_Manager_ (244) id = 165632000] .ropInternal (suspended (exception IllegalArgumentException)) GraphicsInternal (Graphics) (int, int, int, int, int, Bitmap, int, int, boolean) online: 1403 (Graphics) GraphicsInternal .tileRop (int, int, int, int, int, Bitmap, int, int) line: 1492 BitmapBackground.draw (Graphics, XYRect) line: 211 (int, Graphics, int, int, int) ChoiceBox.draw line: 534 MyChoiceField (ChoiceField) .paint (Graphics) line: 1977 MyChoiceField.paint (Graphics) line: 55 MyChoiceField (field) .paintSelf (boolean Graphics (, int, int) line: 4600 ManageDestinationsPage line .paintChild (graphic design, field) $5 (Manager): 2505 ManageDestinationsPage$ 5 (Manager) .subpaint (Graphics) line: 3175 ManageDestinationsPage$ 5 (Manager) .subpaint0 (Graphics) line: 3150 ManageDestinationsPage$ 5 (Manager) .paint (Graphics) line: 2487 ManageDestinationsPage line .paintSelf (graphics, boolean, int, int) $5 (field): 4600 ManageDestinationsPage line .paintSelf (graphics, boolean, int, int) $5 (Manager): 2510 HorizontalFieldManager (Manager) .paintChild (graphic design, field) line : 2505 HorizontalFieldManager.subpaint (Graphics) line: 320 HorizontalFieldManager (Manager) .subpaint0 (Graphics) line: 3150 HorizontalFieldManager (Manager) .paint (Graphics) line: 2487 HorizontalFieldManager (field) (graphs, boolean, int, int) .paintSelf line: 4600 HorizontalFieldManager (Manager) .paintSelf (graphics, boolean, int, int) line: 2510 ManageDestinationsPage line .paintChild (graphic design, field) $4 (Manager): 2505 ManageDestinationsPage$ 4 (Manager) .subpaint (Graphics) line: 3175 ManageDestinationsPage$ 4 (Manager) .subpaint0 (Graphics) line: 3150 ManageDestinationsPage$ 4 (Manager) .paint (Graphics) line : 2487 ManageDestinationsPage$ 4 (field) .paintSelf (boolean, int, int Graphics) line: 4600 ManageDestinationsPage line .paintSelf (graphics, boolean, int, int) $4 (Manager): 2510 VerticalFieldManager (Manager) .paintChild (graphic design, field) line: 2505 VerticalFieldManager.subpaint (Graphics) line: VerticalFieldManager (Manager) .subpaint0 (Graphics) line 575: 3150 VerticalFieldManager (Manager) .paint (Graphics) line: 2487 VerticalFieldManager (field) (graphs, boolean, int, int) .paintSelf line: 4600 VerticalFieldManager (Manager) .paintSelf (graphics, boolean, int, int) line : 2510 TitleStatusManager (Manager) .paintChild (graphic design, field) line: 2505 TitleStatusManager (Manager) .subpaint (Graphics) line: 3175 TitleStatusManager (Manager) .subpaint0 (Graphics) line: 3150 TitleStatusManager (Manager) .paint (Graphics) line: 2487 TitleStatusManager (field) (graphs, boolean, int, int) .paintSelf line: 4600 TitleStatusManager (Manager) .paintSelf (graphics, boolean, int, int) line: 2510 ScreenDelegateManager (Manager) .paintChild (graphic design, field) line: 2505 ScreenDelegateManager (Manager) .subpaint (Graphics) line: 3175 ScreenDelegateManager (Manager) .subpaint0 (Graphics) line : 3150 ScreenDelegateManager (Manager) .paint (Graphics) line: 2487 ScreenDelegateManager (field) (graphs, boolean, int, int) .paintSelf line: 4600 ScreenDelegateManager (Manager) .paintSelf (graphics, boolean, int, int) line: 2510 ManageDestinationsPage (Manager) .paintChild (graphic design, field) line: 2505 ManageDestinationsPage (Screen) .paint (Graphics) line: 4515 ManageDestinationsPage (field) (graphs, boolean, int, int) .paintSelf line: 4600 ManageDestinationsPage (Manager) .paintSelf (graphics, boolean, int, int) line: 2510 ManageDestinationsPage (Screen) .doPaint0 (line): line UiEngineImpl.paintToBackingStores () 1891 : 922 UiEngineImpl.doPainting () line: 734 UiEngineImpl.processMessage (Object Message, boolean) line: 4236 AppStartUp (app) .doProcessNextMessage (Message) line: 2412 AppStartUp (app) .processNextMessage (Message) line: 1639 AppStartUp (app) .enterEventDispatcher (line): 1452 AppStartUp.main (String []) line: 17

    Sorry guys,

    I luckely fell appon a thread which solved my problem.

    http://supportforums.BlackBerry.com/T5/Java-development/differences-between-V5-0-OS-and-V6-0-OS-for-...

    Thanks in any case.

  • I have a lg 4 k tv (40 "40UH630V TV LG ULTRA HD 4 K) with HDMI 2. 0 and if I buy apple tv 4 can be used with HDMI 2. 0 port or do I HDMI 3 port to use this? Please help me

    I have a lg 4 k tv (40 "40UH630V TV LG ULTRA HD 4 K) with HDMI 2. 0 and if I buy apple tv 4 can be used with HDMI 2. 0 port or do I HDMI 3 port to use this? Please help me

    You can use it with your TV.

  • Need help to find an adapter for a third-party monitor

    Hi all! I find myself in need of a little guidance, and I hope that someone out there will have a quick n easy for me...

    I have a Mid-2011 27 'iMac. which has two ports Thunderbolt It is taken with a Wacom tablet that I use constantly, and the other is made by an external hard drive to a solid state, which has a built-in cable to Thunderbolt (no way to hang it on a different port). I also have a 27 "HP monitor that is currently connected via an HDMI USB adapter.

    The problem is that the HP monitor is actual "jiggy" - the USB does not seem fast enough to deal with requests for the monitor. It is almost unusable. I know I should run it via a HDMI adapter Thunderbolt, but as I have already mentioned the two my Thunderbolt ports are already in use.

    Someone at - it ideas? I need sort of three to two ports Thunderbolt hooks, but I can't seem to find anything for less than $300 that would work. (I am illiterate when it comes to the different cables, adapters, ports, etc., so I hope someone can point me in the right direction by using short words... Most of the products that I travel through list specifications that me Chicane).

    The monitor has two HDMIs and a VGA port, and my iMac has a Firewire 800 port, if that helps at all...

    2011 iMac have only 1 Thunderbolt port and there is no such thing as a Mid-2011, you must have an iMac of year later, if it has 2 ports Thunderbolt. All the 27 "iMacs, from 2012 to 2015 the current have 2 ports Thunderbolt.

  • Help with Safari!

    My macbook air from apple not to open the Web page like www.investing.com! Help! Different Web pages all okey, but it's not working!

    Works fine for me.

    What extension you have installed and activated?

    Do you have any adware installed on your MBA?

  • He can't change the region of my account! Help, please! Thank you ~ ~ ~

    Hello

    I want to change my account area. But I still balance ($0.02) so I couldn't change. Please delete my balance.

    Thank you!

    and now I can not contact the Apple Support it's always show

    We're sorry.

    We are unable to respond to your request at this time. Please try again or come back later.

    1c14bb55-ED82-4B43-9c22-fc79914a022c

    is could someone please help me contact the apple support to clear my balance or help me another way to change the region on my account please!

    Thank you!!

  • Sierra is a bomb, need help to return to El Capitan

    Could someone more at Apple just try it once to make sure that the "new and improved" operating systems actually work before releasing? With all the money goes to Cupertino, there is no money to hire testers rather than rely on Mac users? Talk about Stockholm syndrome. I'll cut to the Chase, now my computer has been upgraded to Sierra without my knowledge, and several apps are now, not to mention that I can't access my company's server today. How to return to El Capitan - can I save all my work from today and use Time Machine to restore my machine? If this isn't the case, should I really erase everything and start from scratch? Someone please stop me to jump on a ledge, I have work I need to pass on to customers. Any suggestions, help, you can give would be appreciated. Carl

    Restore your backup, and if you do not upgrade your Mac, who did? Maybe you should tell them not to do the without you knowledge or approval.

  • Make a ringtone on new iTunes - Help!

    I'm doing a song I recently bought into a ringtone for my iPhone 6 s, and each unique tutorial directs turn you into an AAC file, but with the new iTunes, when you right click on the song there no option to turn it into an AAC file. In fact, when I checked the file type of the song, its listed as a "purchased AAC audio file", then, what do you do for a song is already an AAC? Also, I chose a section of the song, which is less than thirty seconds, he saved and still even if he doesn't play that this article, still lists the song duration as full 6 min, not the new article 28 sec, so I even when I duplicate and turn it into a .m4r and do all the other steps , it will not transfer because it is too long.

    It's really frustrating! Help!

    I do not use the new iTunes so I can't test anything.  You've always been able to convert AAC AAC; for example, when wanting a lower bitrate copy.

    12 iTunes for Mac: save a copy of a song in a new file format: http://support.apple.com/kb/PH19509 - make sure that you are not using the full screen: https://discussions.apple.com/thread/6777547 - in iTunes 12.4 left the contextual to menu: file > create a new Version > Create [format] Version - example with image: https://discussions.apple.com/message/30405263#message30405263 + ' If you hold the option key menu SUP to convert changes in...» »

    May 2016, some changes in iTunes 12.4 - https://discussions.apple.com/thread/7564256

    Of course, my dynamic point of view on this would be to use a different converter or an audio editor.  MPEGStreamclip, Audacity, Gargeband

  • After my 10 updated iOS even if I am connected to view the content I have cloud and iCloud when I try it asks me to put in place when already established sound upward. Help, please

    After the last update of iOS10. Even though I am connected to iCloud when I try to display the content he asks me to implement the iCloud. Can anyone help please.

    Try to perform a restart- restart your iPhone, iPad or iPod touch - Apple Support

  • My AirPort Extreme end not implemented with the help of AirPort Utility

    Bought a used AirPort Extreme (Genesis 4) of a person who showed me that he worked at home. When I try to set up as a Wireless extender to my last existing AirPort Extreme, he will not carry out synchronization upward with AirPort Utility. It appears as a new extreme, but get a message 'unexpected error' before or after the name. Have you tried to reset the two while it is powered and turning the as explained in the help.

    When I try to set up as a Wireless extender...

    Gen 4 airport will connect to your existing AirPort Extreme wireless... or... it will connect using wired Ethernet wired, Permanent?

    .. .it will not accomplish the synchronization upward with AirPort Utility.

    Which version of AirPort Utility?  If it's on your Mac... and you don't know what version you have...

    Open AirPort Utility

    Click the AirPort Utility menu in the upper left corner of the screen

    Click on about AirPort Utility

    Report on the version number you see here

    You have an iPhone or a handy iPad that could be used to implement the 4th Gen airport if the problems continue with the help of your Mac?

  • With the help of iPhone 6 s. try to copy the text message with a tap double and get a bubble with icons. How can I copy the message to paste in another?

    Try to copy a text to paste in another. When I double tap, as I always have, all I get is a bubble with icons on it. With the help of OS 10.0.2.

    maryml wrote:

    Try to copy a text to paste in another. When I double tap, as I always have, all I get is a bubble with icons on it. With the help of OS 10.0.2.

    Press and hold on the text and wait for the copy/more pop up.

  • I am tryng to buying music on itunes, but it says security code wrong please help

    Hello

    I have problems I want tp purchase music on my itunes bt ts always requires the security code that I don't have it please help

    Check your card information. If they are correct, try to change or remove your Apple ID - Apple Support payment information

  • Can anyone help? -videos on the desktop

    Hi all

    I took a few videos using my iPhone 6 + and that you want to transfer the files on my desktop Mac, so I can change them etc as I hear it.

    However, I am having a LOT of WRONG doing.

    Some of the smaller files for only a minute or two in length seems to have yielded with success, but those

    4 min and especially just transfer not together at all.

    I remember other times - with the old iPhotos etc. - I've never had this problem. All I had to do was simply 'import' those I want to import and then drag and drop them in front of iPhotos on my desk. It simply no longer work

    I also tried to export directly from my iPhone to Dropbox (I just keep getting an error after 'preparation'), iCloud, photo sharing (told me that the video/s is / are too long and cut the shorter... I don't want to get)... I've tried everything!

    I tried also to AirDrop and even if it is enabled on my iPhone AND my Mac... Mac does not appear under "Parachuting" of the iPhone and so I have nothing to synchronize with.

    Appreciating any help.

    Concerning

    D

    A question can be with your connection - WiFi

    Have you tried to connect the phone with a lightning USB wire and import via iTunes?

Maybe you are looking for