长按按钮

时间:2017-05-29 19:12:29

标签: android

我正在编写自己的键盘。在我的标记中有两个字母的按钮。当你按下一次我们把字母е,当我们推动合同2次时,我们把字母ё。如何按下按钮很长一段时间,你把字母ё?

<?xml version="1.0" encoding="utf-8"?>
<Keyboard xmlns:android="http://schemas.android.com/apk/res/android"
    android:keyWidth="7.5%p"
    android:horizontalGap="5px"
    android:verticalGap="10px"
    android:keyHeight="48dp">

    <Row>
        <Key android:codes="1081" android:keyLabel="й" android:keyEdgeFlags="left" />
        <Key android:codes="1094" android:keyLabel="ц" />
        <Key android:codes="1091" android:keyLabel="у" />
        <Key android:codes="1082" android:keyLabel="к" />
        <Key android:codes="1077,1105" android:keyLabel="е ё" />
        <Key android:codes="1085" android:keyLabel="н" />
        <Key android:codes="1075" android:keyLabel="г" />
        <Key android:codes="1096" android:keyLabel="ш" />
        <Key android:codes="1097" android:keyLabel="щ" />
        <Key android:codes="1079" android:keyLabel="з" />
        <Key android:codes="1093" android:keyLabel="х" />
        <Key android:codes="1100,1098" android:keyLabel="ь ъ" android:keyEdgeFlags="right" />
    </Row>
    <Row>
        <Key android:codes="1092" android:keyLabel="ф" android:horizontalGap="5%" android:keyEdgeFlags="left" />
        <Key android:codes="1099" android:keyLabel="ы" />
        <Key android:codes="1074" android:keyLabel="в" />
        <Key android:codes="1072" android:keyLabel="а" />
        <Key android:codes="1087" android:keyLabel="п" />
        <Key android:codes="1088" android:keyLabel="р" />
        <Key android:codes="1086" android:keyLabel="о" />
        <Key android:codes="1083" android:keyLabel="л" />
        <Key android:codes="1076" android:keyLabel="д" />
        <Key android:codes="1078" android:keyLabel="ж" />
        <Key android:codes="1101" android:keyLabel="э" android:keyEdgeFlags="right" />
    </Row>
    <Row>
        <Key android:codes="-1" android:keyIcon="@drawable/ic_keyboard_capslock_white_24dp"
            android:keyWidth="13%p" android:keyEdgeFlags="left" />
        <Key android:codes="1103" android:keyLabel="я" />
        <Key android:codes="1095" android:keyLabel="ч" />
        <Key android:codes="1089" android:keyLabel="с" />
        <Key android:codes="1084" android:keyLabel="м" />
        <Key android:codes="1080" android:keyLabel="и" />
        <Key android:codes="1090" android:keyLabel="т" />
        <Key android:codes="1073" android:keyLabel="б" />
        <Key android:codes="1102" android:keyLabel="ю" />
        <Key android:codes="-5" android:keyIcon="@drawable/ic_backspace_white_24dp"
            android:isRepeatable="true" android:keyEdgeFlags="right" android:keyWidth="13%p" />
    </Row>
    <Row android:rowEdgeFlags="bottom">
        <Key android:codes="-6" android:keyLabel="\?123" android:keyWidth="16%p" android:keyEdgeFlags="left"/>
        <Key android:codes="-2" android:keyIcon="@drawable/ic_language_white_24dp" />
        <Key android:codes="44" android:keyLabel=","/>
        <Key android:codes="32" android:keyLabel=" " android:keyWidth="29%p" android:isRepeatable="true"/>
        <Key android:codes="46" android:keyLabel="." />
        <Key android:codes="-4" android:keyIcon="@drawable/ic_keyboard_return_white_24dp"
            android:keyWidth="19%p" android:keyEdgeFlags="right"/>
    </Row>

</Keyboard>

1 个答案:

答案 0 :(得分:0)

尝试使用:

public boolean onKeyLongPress(int keyCode, KeyEvent event)