2011-05-06 21 views

回答

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")); 
} 
} 
+0

在上面的代碼切換到另一個屏幕時,選擇opt 3,我需要任何選項。 – Kotibab 2011-05-06 12:49:26

+0

嗯,然後刪除fieldChanged中的if-clause並調用openAnotherForm()。 – Richard 2011-05-09 11:59:43