LWUIT 1.4 - 为什么在文本字段编辑期间首次显示后不显示虚拟键盘?

时间:2011-12-15 14:33:48

标签: java-me lwuit lwuit-textfield lwuit-vkb

我想在用户编辑virtual keyboard时显示textfield。我采用这种方法:

public class ChpModif extends TextField {

    public ChpModif(int maxChars, FocusListener focusListener, DataChangedListener dataChangeListener, VirtualKeyboard vkb)
    {
        super();
        setReplaceMenu(false);
        if (maxChars != -1)
            setMaxSize(maxChars);
        addFocusListener(focusListener);
        addDataChangeListener(dataChangeListener);
        if (vkb != null)
            VirtualKeyboard.bindVirtualKeyboard(this, vkb);
    }
    protected Command installCommands(Command clear, Command t9)
    {
        return null;
    }
}

public class ModifierFicheClient extends Ecran implements ActionListener, DataChangedListener, FocusListener
{
    private VirtualKeyboard vkNombre = new VirtualKeyboard();
    private String textFieldStatus, listBoxStatus;
    private ListBox genretxt;
    private boolean modifFromUpdate;
    private ChpModif nomtxt,prenomtxt,cintxt,adressetxt/*,genretxt*/,lieutxt,professiontxt,courieltxt,teltxt,datenaisstxt;
    private Component cursorItem;
    ...
    public ModifierFicheClient(SmartPhoneBanking controller,String prosp_id,int recordStoreID,Form prevForm)
    {
        super("");
        vkNombre.setInputModeOrder(new String[]{VirtualKeyboard.NUMBERS_SYMBOLS_MODE});
        ...
        modifFromUpdate = false;
        cintxt = new ChpModif(12, this, this, vkNombre);
        ...
    }
    public void dataChanged(int type, int index) {
        textFieldStatus = "CHANGED";
        if (!modifFromUpdate)
        {
            try
            {
                if (type == DataChangedListener.ADDED || type == DataChangedListener.CHANGED || type == DataChangedListener.REMOVED)
                {
                    if (Display.getInstance().isVirtualKeyboardShowingSupported())
                    {
                        if (!Display.getInstance().isVirtualKeyboardShowing())
                            cursorItem.pointerReleased(cursorItem.getAbsoluteX(), cursorItem.getAbsoluteY());
                    }
                }
            }
            catch (ClassCastException cce)
            {}
        }
    }
    public void focusGained(Component chp) {
        cursorItem = chp;
    }
    public void focusLost(Component arg0) {
    }
    protected void onShowCompleted()
    {
        ...
        update();
    }
    public void update()
    {
        modifFromUpdate = true;
        cintxt.setText(fichesignalitique.elementAt(0).toString());
        ...
        modifFromUpdate = false;
    }
    ...
}

问题在于,当我第一次编辑textfield时,会显示virtualkeyboard;然后,我点击Ok的{​​{1}}按钮,然后再次编辑virtualkeyboard。但是在这个时候textfield没有显示!

那么每次编辑virtualkeyboard时如何显示virtualkeyboard

1 个答案:

答案 0 :(得分:1)

完全有可能这是一个在1.5中修复的1.4错误,因为我现在看不到它。 VKB在1.4中是全新的。