Android Custom keyboard

只愿长相守 提交于 2019-12-19 11:26:47

问题


I creating custom keyboard using this link "http://www.fampennings.nl/maarten/android/09keyboard/index.htm" but i want to include so many word into this keyboard,above link keyboard looks like follwing :

i have three xml file : 1) hexkbd : have A to N 2) hexkbd2 : M to Z 3) hexkbd3) extra word, i display first xml file well, but i want to put one extra button into this keyboard to change above all three xml to change keyboard a to n to m to z, but i dont know how to do this in this custom keyboard.for example in above image i put number in another xm file,alphabet in another xml file, and other extra word in another file, we put same one button in all this xml file to change all three sequential,in first click on this same button display only number keyboard,second click alpha keyboard as all,what i have to do in this button and how, any one please help me quick ? thanks in advance.

i want following type :


回答1:


I find my own answers,it simple i just to add one same button in all xml file like

in hexkbd : in key tag

        android:keyEdgeFlags="right"
        android:codes="35"
        android:isRepeatable="true"
        android:keyIcon="@drawable/img_change_key" 

in hexkbd2

        android:keyEdgeFlags="right"
        android:codes="38"
        android:isRepeatable="true"
        android:keyIcon="@drawable/img_change_key" 

and in CustomKeyboard class KeyboardActionListener decalare :

        public final static int ChangeKey1 = 35;
        public final static int ChangeKey2 = 38;

and in CustomKeyboard class onKey() event :

        ...else if (primaryCode == ChangeKey1) {

            mKeyboardView.setKeyboard(new Keyboard(mHostActivity,
                    R.xml.hexkbd2));

        } else if (primaryCode == ChangeKey2) {

            mKeyboardView.setKeyboard(new Keyboard(mHostActivity,
                    R.xml.hexkbd));

        }

done,it simple,but my confusion take time,i share my idea to help to other persons.i think this helpful to others.



来源:https://stackoverflow.com/questions/24646580/android-custom-keyboard

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!