Диалоговое окно с текстовым полем в Blackberry - PullRequest
0 голосов
/ 19 января 2012

Как я могу получить диалоговое окно с вводом текстового поля, чтобы я мог заставить пользователя ввести ПИН-код?

Ответы [ 3 ]

0 голосов
/ 20 января 2012

Вы можете создать 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 голосов
/ 29 января 2012

Или вы можете взглянуть на мой пост в блоге, чтобы получить информацию из пользовательского диалога здесь .

0 голосов
/ 20 января 2012

Вы можете сделать один Popup screen, чтобы удовлетворить ваши требования.См. документ здесь .А для реализации см. Этот вопрос на 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);

}

}
...