自定义键盘符号代码android

时间:2012-10-09 14:08:54

标签: android android-layout android-widget

我有一个带数字和字母的自定义键盘。我需要在键盘上显示符号。

keyboard.xml as

<?xml version="1.0" encoding="utf-8"?>
<Keyboard xmlns:android="http://schemas.android.com/apk/res/android"
    android:keyWidth="10%p"
    android:horizontalGap="0px"
    android:verticalGap="0px">
   <Row>
    <Key android:codes="8" android:keyLabel="1" android:keyEdgeFlags="left"/>
        <Key android:codes="9" android:keyLabel="2"/>
        <Key android:codes="10" android:keyLabel="3"/>
        <Key android:codes="11" android:keyLabel="4"/>
        <Key android:codes="12" android:keyLabel="5"/>
        <Key android:codes="13" android:keyLabel="6"/>
        <Key android:codes="14" android:keyLabel="7"/>
        <Key android:codes="15" android:keyLabel="8"/>
        <Key android:codes="16" android:keyLabel="9"/>
        <Key android:codes="7" android:keyLabel="0" android:keyEdgeFlags="right"/>
   </Row>
    <Row>
        <Key android:codes="45" android:keyLabel="q" android:keyEdgeFlags="left"/>
        <Key android:codes="51" android:keyLabel="w"/>
        <Key android:codes="33" android:keyLabel="e"/>
        <Key android:codes="46" android:keyLabel="r"/>
        <Key android:codes="48" android:keyLabel="t"/>
        <Key android:codes="53" android:keyLabel="y"/>
        <Key android:codes="49" android:keyLabel="u"/>
        <Key android:codes="37" android:keyLabel="i"/>
        <Key android:codes="43" android:keyLabel="o"/>
        <Key android:codes="44" android:keyLabel="p" android:keyEdgeFlags="right"/>
    </Row>

    <Row>
        <Key android:codes="29" android:keyLabel="a" android:horizontalGap="5%p"
                android:keyEdgeFlags="left"/>
        <Key android:codes="47" android:keyLabel="s"/>
        <Key android:codes="32" android:keyLabel="d"/>
        <Key android:codes="34" android:keyLabel="f"/>
        <Key android:codes="35" android:keyLabel="g"/>
        <Key android:codes="36" android:keyLabel="h"/>
        <Key android:codes="38" android:keyLabel="j"/>
        <Key android:codes="39" android:keyLabel="k"/>
        <Key android:codes="40" android:keyLabel="l" android:keyEdgeFlags="right"/>
    </Row>

    <Row>
        <Key android:codes="54" android:keyLabel="z" android:horizontalGap="5%p"
                android:keyEdgeFlags="left"/>
        <Key android:codes="52" android:keyLabel="x"/>
        <Key android:codes="31" android:keyLabel="c"/>
        <Key android:codes="50" android:keyLabel="v"/>
        <Key android:codes="30" android:keyLabel="b"/>
        <Key android:codes="42" android:keyLabel="n"/>
        <Key android:codes="41" android:keyLabel="m"/>
         <Key android:codes="-3" android:keyLabel="Done"/>
        <Key android:codes="67" android:keyLabel="Delete"
                android:keyWidth="15%p" android:keyEdgeFlags="right"
                android:isRepeatable="true"/>
    </Row>

    <Row android:rowEdgeFlags="bottom">
        <Key android:codes="-3" android:keyLabel="\@" android:horizontalGap="20%p"
                android:keyWidth="15%p" android:keyEdgeFlags="left"/>
        <Key android:codes="-2" android:keyLabel=".com" android:keyWidth="15%p"/>
        <Key android:codes="-1" android:keyLabel="-"
                android:keyWidth="15%p" />
        <Key android:codes="-4" android:keyLabel="."
                android:keyWidth="15%p" android:keyEdgeFlags="right"/>
    </Row>
</Keyboard>

我想显示符号和下一个选项来移动listview中的另一个编辑text.edit文本.Listview包含textview和编辑text.help我来解决这个问题。

1 个答案:

答案 0 :(得分:0)

要显示符号,您必须在点击任何按钮时创建另一个xml并切换(更改键盘设计)

<强> Symbols.xml

<?xml version="1.0" encoding="utf-8"?>
<Keyboard android:keyWidth="10.000002%p" android:keyHeight="@dimen/key_height" android:horizontalGap="0.0px" android:verticalGap="4.0px"
  xmlns:android="http://schemas.android.com/apk/res/android">
    <Row>
        <Key android:codes="49" android:keyEdgeFlags="left" android:keyLabel="1" />
        <Key android:codes="50" android:keyLabel="2" />
        <Key android:codes="51" android:keyLabel="3" />
        <Key android:codes="52" android:keyLabel="4" />
        <Key android:codes="53" android:keyLabel="5" />
        <Key android:codes="54" android:keyLabel="6" />
        <Key android:codes="55" android:keyLabel="7" />
        <Key android:codes="56" android:keyLabel="8" />
        <Key android:codes="57" android:keyLabel="9" />
        <Key android:codes="48" android:keyEdgeFlags="right" android:keyLabel="0" />
    </Row>
    <Row>
        <Key android:codes="64" android:keyEdgeFlags="left" android:keyLabel="\@" />
        <Key android:codes="35" android:keyLabel="\#" />
        <Key android:codes="36" android:keyLabel="$" />
        <Key android:codes="37" android:keyLabel="%" />
        <Key android:codes="38" android:keyLabel="&amp;" />
        <Key android:codes="42" android:keyLabel="*" />
        <Key android:codes="45" android:keyLabel="-" />
        <Key android:codes="61" android:keyLabel="=" />
        <Key android:codes="40" android:keyLabel="(" />
        <Key android:codes="41" android:keyEdgeFlags="right" android:keyLabel=")" />
    </Row>
    <Row>
        <Key android:keyWidth="14.999998%p" android:codes="-1" android:keyEdgeFlags="left" android:isModifier="true" android:isSticky="true" android:keyIcon="@drawable/sym_keyboard_shift" />
        <Key android:codes="33" android:keyLabel="!" />
        <Key android:codes="34" android:keyLabel="&quot;" />
        <Key android:codes="39" android:keyLabel="'" />
        <Key android:codes="58" android:keyLabel=":" />
        <Key android:codes="59" android:keyLabel=";" />
        <Key android:codes="47" android:keyLabel="/" />
        <Key android:codes="63" android:keyLabel="\?" />
        <Key android:keyWidth="14.999998%p" android:codes="-5" android:keyEdgeFlags="right" android:isRepeatable="true" android:keyIcon="@drawable/sym_keyboard_delete" />
    </Row>
    <Row android:rowEdgeFlags="bottom">
        <Key android:keyWidth="14.999998%p" android:codes="-11" android:keyLabel="ABC" />
        <Key android:keyWidth="13.999998%p" android:codes="-10" android:keyIcon="@drawable/e405" />
        <Key android:keyWidth="35.99999%p" android:codes="32" android:isRepeatable="true" android:keyIcon="@drawable/sym_keyboard_space" />
        <Key android:keyWidth="14.999998%p" android:codes="44" android:keyLabel="," />
        <Key android:keyWidth="20.000004%p" android:codes="10" android:keyEdgeFlags="right" android:keyIcon="@drawable/sym_keyboard_return" />
    </Row>
</Keyboard>