在黑莓中选择一个对象选择字段时切换到新屏幕

时间:2011-05-06 10:40:10

标签: blackberry java-me

任何人都可以告诉我在选择其中一个ObjectChoiceField时切换到另一个屏幕。

谢谢。

1 个答案:

答案 0 :(得分:4)

final class HelloWorldScreen extends MainScreen implements FieldChangeListener
{
        ObjectChoiceField choice=null;
        public HelloWorldScreen()
        {
                super();
                String choicestrs[] = {"Opt 1", "Opt 2", "Opt 3"};
                choice = new ObjectChoiceField("Object Choice Field: ", choicestrs, 0);
                choice.setChangeListener(this);
            add(choice);
    }
    public void openAnotherForm(){
        AnotherForm newScreen = new AnotherForm();
        UiApplication.getUiApplication().pushScreen(newScreen);
    }
    public void fieldChanged(Field arg0, int arg1) {
        openAnotherForm();

    }
}
class AnotherForm extends MainScreen
{
public AnotherForm()
{
        super();
        add(new LabelField("Another Form"));
}
}