Pergunta

How to programmatically open/close or force the virtual keyboard to open in reduced form in Blackberry?

I tried searching it but couldn't find a way to do it.

I also tried finding some links in Blackberry Support Forums like

http://supportforums.blackberry.com/t5/Java-Development/Blackberry-torch-force-reduced-virtual-keyboard-layout/td-p/618989

But this was not helpful.

EDIT:

Here is the code I am using to define my editField:

/** Horizontal field manager to hold text field*/
  HorizontalFieldManager hfmBadgeNo = new HorizontalFieldManager(FIELD_HCENTER)
  {
   protected void paintBackground(Graphics graphics) {
    graphics.setColor(Color.DARKGRAY);
    graphics.drawRoundRect(60, 10, Display.getWidth() - (60 * 2), getField(0).getHeight() + 10, 5, 5);

    super.paintBackground(graphics);
   }
  };

  // text field to enter Badge Number, it allows only Numeric Digits
  EditField txtEventNumber = new EditField() {
   public void paint(Graphics graphics) {
    super.paint(graphics);
    int oldColor = Color.GRAY;
    graphics.setBackgroundColor(Color.WHITE);
    graphics.setColor(0x181818);
    Font font = this.getFont().derive(Font.EMBOSSED_EFFECT, 54);
    this.setFont(font);
    graphics.setColor(oldColor);
    super.paint(graphics);
   }
   protected void onFocus(int direction) {
    if (VirtualKeyboard.isSupported())
     // Show keyboard
     getScreen().getVirtualKeyboard().setVisibility(VirtualKeyboard.SHOW);
    this.setCursorPosition(this.getTextLength());
    invalidate();
    super.onFocus(direction);
   };
   protected void onUnfocus() {
    if (VirtualKeyboard.isSupported())
     // Hide keyboard
     getScreen().getVirtualKeyboard().setVisibility(VirtualKeyboard.HIDE_FORCE);
    this.setCursorPosition(this.getTextLength());
    invalidate();
    super.onUnfocus();
   };
  };
  // Allows numeric value
  txtEventNumber.setFilter(TextFilter.get(TextFilter.NUMERIC));
  txtEventNumber.setMargin(10 + 5, 60 + 5, 5, 60 + 5);

  // Add text field to manager
  hfmBadgeNo.add(txtEventNumber);

Reduced Keyboard is as follows:

enter image description here

Full keyboard is as follows:

enter image description here

Foi útil?

Solução

BlackBerry Java based devices (BlackBerry OS up to and including 7.1) The keyboard is determined by the TextFilter in effect for the input field with focus. There are a number of predefined filters that can be specified in the field constructor style argument. Or you can create your own filter, either from scratch or by combining the existing ones, if none of those meet your needs.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top