黑莓手机:自动打开简化键盘

时间:2013-01-10 05:36:03

标签: blackberry java-me virtual-keyboard

如何以编程方式打开/关闭或强制在Blackberry中以缩小的形式打开虚拟键盘?

我试过搜索它但找不到办法。

我也尝试在Blackberry支持论坛中找到一些链接,比如

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);

简化键盘如下:

enter image description here

全键盘如下:

enter image description here

1 个答案:

答案 0 :(得分:2)

基于BlackBerry Java的设备(BlackBerry OS至7.1及以下)键盘由具有焦点的输入字段生效的TextFilter确定。可以在字段构造函数样式参数中指定许多预定义过滤器。或者,您可以从头开始创建自己的过滤器,或by combining the existing ones,如果这些过滤器都不能满足您的需求。