黑莓:自动打开缩小键盘

标签 blackberry java-me virtual-keyboard

如何以编程方式打开/关闭或强制在 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

最佳答案

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

关于黑莓:自动打开缩小键盘,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14251438/

相关文章:

java - 计算富文本字段中可能的行数

java - Blackberry - 字段 - 水平对齐

java - 黑莓对话框

java - J2ME 中的 HTTP 身份验证

c# - 子字符串和索引

ios5 - iOS 5 固定定位和虚拟键盘

python - QLineEdit PyQT5 输入上的火柴盒键盘

sqlite - 黑莓 SQLite 批量删除最佳实践

java - 为什么数字约束在 LWUIT 中的虚拟键盘上不起作用?

iOS 在 View 更改时关闭键盘