0

我想显示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;
    }
    ...
}

问题是,当我第一次编辑时textfieldvirtualkeyboard会显示;然后我单击 的Ok按钮virtualkeyboard,然后我再次编辑textfield. 但是在这个时候virtualkeyboard没有显示!

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

4

1 回答 1

1

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

于 2011-12-18T05:05:31.243 回答