2012-01-19 63 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