java-meactionlistenerlwuitnokia-s40

PopupChoiceGroup actionlistener won't work on Asha 501


I'm currently making an app for Asha phones, both the 3xx series and the new 5xx ones.

I already have the code working on the 3xx series such as Asha 310 and 311, but for some reason, when I compile and try it on Asha 501 phones, it doesn't work..

I'm getting the 'Radio 1 clicked!!!' message on the Asha 310's emulator console, but not on the Asha 501.

I'm using Nokia Java SDK 2.0 for the Asha 310/311 and Nokia Asha SDK 1.1 for the Asha 501 phones and the proper Asha LWUIT libraries that comes inside the SDKs.

Does anyone have an idea why it's working on the older Asha phones but not the new ones?

        Form form = new Form("Testing form");
        RadioButton choices[] = new RadioButton[2];
        RadioButton radioButton1 = new RadioButton("Radio 1");
        RadioButton radioButton2 = new RadioButton("Radio 2");

        choices[0] = radioButton1;
        choices[1] = radioButton2;
        PopupChoiceGroup popupChoiceGroup = new PopupChoiceGroup("Testing", choices);

        radioButton1.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                System.out.println("Radio 1 clicked!!!");
            }
        });

        radioButton2.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent evt) {
                System.out.println("Radio 2 clicked!!!");
            }
        });
        form.addComponent(popupChoiceGroup);

        form.show();

Edit: I'm using phone emulators so I can see the outputs.


Solution

  • I would suggest downloading LWUIT separately and testing with various versions. Another suggestion is to extend the PopupChoiceGroup as your own class and then dive into the source code for PopupChoiceGroup, adding snippets and debugging as you go along. The quirks of LWUIT are best dealt with in its source, it is best to extend and then modify the behaviour, it really is not as daunting as it seems.