2012-01-19 54 views

回答

0

您可以讓一個Popup screen滿足您的要求。請參閱Document here。並執行see this question on stackOverFlow

這裏是你可以改變你的要求換貨

public class PinPopup extends PopupScreen //implements FieldChangeListener 
{ 
public static EditField texts; 


PinPopup() 
{ 
super(new HorizontalFieldManager()); 
Font f = Font.getDefault().derive(Font.BOLD, 16); 
setFont(f); 
texts=new EditField("Pin: ","",15 , Field.EDITABLE); 


ButtonField sendButton = new ButtonField(" Send "){ 
    protected boolean navigationClick(int status, int time) { 
     //Do something with button 
     return true; 
     } 



}; 

ButtonField cancelButton = new ButtonField("Cancel"){ 
    protected boolean navigationClick(int status, int time) { 
      //Do something with button 
     return true; 
     } 
}; 

Manager _fieldManagerContext = new Manager(USE_ALL_WIDTH) 
    { 

    public void sublayout(int width,int height) {     
     //super.sublayout(width, height); 
     int xpos = 10; 
     int ypos = 40; 

     Field field = getField(0); 
     layoutChild(field, 280, 50); 
     setPositionChild(field, xpos, ypos); 

     Field field1 = getField(1); 
     layoutChild(field1, 280, 50); 
     setPositionChild(field1, xpos, ypos+40); 

     Field field2 = getField(2); 
     layoutChild(field2, 280, 50); 
     setPositionChild(field2, xpos+20, ypos+100); 


     setPosition(300, 300); 
     setExtent(300, 300); 

     } 
      public void paint(Graphics graphics) 
      { 
       //graphics.setColor(Color.WHITE); 
       Font f = Font.getDefault().derive(Font.BOLD, 16); 
       graphics.setFont(f); 
       graphics.drawText("SEND PIN",90, 20,0,200); 
       //graphics.drawText(_userName,110,40,0,200); 
       graphics.setColor(Color.WHITE); 
       super.paint(graphics);      
      } 

    }; 

      _fieldManagerContext.add(texts); 
      _fieldManagerContext.add(sendButton); 
      _fieldManagerContext.add(cancelButton); 
      add(_fieldManagerContext); 

} 

} 
0

您可以創建一個CustomDialog延伸屏幕的代碼。這也將幫助您獲取用戶在文本框中輸入的引腳值。

public class CustomDialog extends Screen 
{ 

    public CustomDialog() 
    { 
      super(new VerticalFieldManager(), Screen.DEFAULT_CLOSE); 
      //add the whole UI here 
    } 

//control the height and width of the Dialog with the help of this function 

    protected void sublayout(int width, int height) 
    { 
     layoutDelegate(width - 80, height - 80); 
     setPositionDelegate(10, 10); 
     setExtent(width - 60, Math.min(height - 60, getDelegate().getHeight() + 20)); 
     setPosition(30, (height - getHeight())/2);  // sets the position on the screen 
    } 
} 

試試這個希望這會對你有幫助。

同時呼籲該對話框,請參閱下面的代碼..

UiApplication.getUiApplication().invokeLater(new Runnable() 
     { 
      public void run() 
      { 
       UiApplication.getUiApplication().pushModalScreen(new CustomDialog()); 
      } 
     }); 
+0

非常感謝你Swati!但它會拋出非法狀態異常。我應該把這個類作爲內部類嗎?要麼?? – Roses

+1

我有jst編輯我的代碼.. – Swati

0

或者你可以看看從一個自定義對話框here讓輸入我的博客文章。

+0

偉大的理查它爲我工作! :) – Roses