2

如何以编程方式打开/关闭或强制虚拟键盘在黑莓中以简化形式打开?

我尝试搜索它,但找不到方法。

我还尝试在黑莓支持论坛中找到一些链接,例如

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

但这没有帮助。

编辑:

这是我用来定义我的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);

精简键盘如下:

在此处输入图像描述

全键盘如下:

在此处输入图像描述

4

1 回答 1

2

基于 BlackBerry Java 的设备(BlackBerry OS 最高并包括 7.1) 键盘由TextFilter确定,对具有焦点的输入字段有效。可以在字段构造函数样式参数中指定许多预定义的过滤器。或者,如果这些都不能满足您的需求,您可以从头开始或组合现有的过滤器来创建自己的过滤器。

于 2013-01-10T14:18:59.227 回答