如何以编程方式打开/关闭或强制虚拟键盘在黑莓中以简化形式打开?
我尝试搜索它,但找不到方法。
我还尝试在黑莓支持论坛中找到一些链接,例如
但这没有帮助。
编辑:
这是我用来定义我的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);
精简键盘如下:
全键盘如下: