Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android KeyBoard.Key disable iconPreview of special keys?

I customize my own soft keyboard by implementing the KeyboardView.OnKeyboardActionListener interface.

When the keys are pressed, it will show a preview popup.

My problem is how to disable the preview popup for special keys such as SHIFT and DELETE?

I have tried to set the android:iconPreview attribute to null but it didn't work.

<Key
    android:codes="-1"
    android:keyIcon="@drawable/key_shift" 
    android:keyWidth="15%p"
    android:isModifier="true"
    android:isSticky="true"
    android:keyEdgeFlags="left" />

Have any idea?

Thanks in advance!

like image 361
John Smith Avatar asked Nov 18 '11 10:11

John Smith


People also ask

Where is the key on an Android keyboard?

Key is anchored to the left of the keyboard. Key is anchored to the right of the keyboard.


1 Answers

First you must implement OnKeyboardActionListener

then use onPress() and onRelease() to control the preview popup like this:

public void onPress(int primaryCode) {
    if (primaryCode==-2||primaryCode==-5||primaryCode==-4){
        mInputView.setPreviewEnabled(false);
    }
}

public void onRelease(int primaryCode) {
    mInputView.setPreviewEnabled(true);
}
like image 62
sunset Avatar answered Sep 27 '22 19:09

sunset