如何以编程方式打开/关闭或强制在 Blackberry 中以简化形式打开虚拟键盘?
我尝试搜索它,但找不到方法。
我还尝试在黑莓支持论坛中找到一些链接,例如
但这没有帮助。
编辑:
这是我用来定义 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);
简化键盘如下:
全键盘如下:
最佳答案
基于 BlackBerry Java 的设备(BlackBerry OS 7.1 及以上版本) 键盘由 TextFilter 确定对于具有焦点的输入字段有效。有许多预定义的过滤器可以在字段构造函数样式参数中指定。或者您可以从头开始创建自己的过滤器或 by combining the existing ones ,如果这些都不能满足您的需求。
关于黑莓:自动打开缩小键盘,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14251438/