Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove repeatable keys, key preview of the Android custom keyboard

How to remove repeating keys, key preview of Android Custom Keyboard. I used following method to remove key preview of the keys that I want. But that method is not working for repeatable keys. (android:isRepeatable="true") If the key is not repeatable, following method is working.

delete key xml

<Key android:codes="-5"
        android:keyWidth="13%p"
        android:keyIcon="@drawable/ic_key_delete_white"
        android:keyBackground="@color/dark_key_background"
        android:isRepeatable="true"
        android:horizontalGap="3.5%p"
        android:keyEdgeFlags="right"/>

Input method service Class

@Override
public void onPress(int primaryCode) {
    if (primaryCode == -1 
            || primaryCode == -5){
        kv.setPreviewEnabled(false);
    }
}

@Override
public void onRelease(int primaryCode) {
    if(primaryCode == -1 
            || primaryCode == -5){
        kv.setPreviewEnabled(true);
    }
}
like image 337
Arvin Jayanake Avatar asked Feb 23 '15 04:02

Arvin Jayanake


People also ask

How to hide keyboard when Click on button in Android?

Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main.xml. Step 3 Add the following code to src/MainActivity.java In the above code when you click on the button it will hide keyboard.

How to take keys off a keyboard?

How to Take Keys Off a Keyboard Method 1 of 3: Removing Keys with a Keycap Puller. Acquire a keycap puller tool from an electronics repair shop or... Method 2 of 3: Using Household Tools. Use a flathead screwdriver or butter knife as an alternative to a keycap puller. Method 3 of 3: Cleaning and ...

How do I enable my keyboard on my Android phone?

Tap the “Manage Keyboard” option to see the currently installed keyboards. You should see your newly installed keyboard app there as well, but it will be disabled. Tap the toggle next to the keyboard’s name to enable it. A warning appears onscreen letting you know that the keyboard has to collect the text your type.

How do I change my keyboard to SwiftKey on Android?

On the setup screen, tap the “Select Swiftkey” option. You’ll see a dialog box titled “Change Keyboard” with your current default keyboard selected (in this example, it’s the Fleksy keyboard). Tap the Swiftkey Keyboard option to select it.


1 Answers

Revers setPreviewEnabled flag..

public void onCreate() {

    mInputView.setPreviewEnabled(false);

}

public void onPress(int primaryCode) {
    if (primaryCode==-1||primaryCode==-2||primaryCode==-5||primaryCode==-4){

    } else {
       mInputView.setPreviewEnabled(true);
    }
}

public void onRelease(int primaryCode) {
    mInputView.setPreviewEnabled(false);
}
like image 120
James Hong Avatar answered Sep 28 '22 23:09

James Hong