2014-07-09 162 views
1

我使用这个链接http://www.fampennings.nl/maarten/android/09keyboard/index.htm创建自定义键盘,但我想有这么多的字为这个键盘,上面的链接键盘看起来像follwing:Android的自定义键盘

enter image description here

我有三个XML file:1)hexkbd:有A到N 2)hexkbd2:M到Z 3)hexkbd3)额外的单词,我很好地显示第一个xml文件,但是我想在这个键盘上添加一个额外的按钮来改变以上所有三个xml来改变键盘a到n到m到z,但我不知道如何做到这一点在这个自定义键盘。例如在上面的图像我把数字放在另一个xm文件,字母表在另一个xml文件,另一个文件中的其他额外的单词,我们把所有这个XML文件中相同的一个按钮,以改变所有三个连续的,在第一次点击这个相同的按钮显示只有数字键盘,第二次单击字母键盘作为所有,我必须做的这个按钮和如何,任何人请快速帮我快点?提前致谢。

我想以下类型: enter image description here

回答

1

我找到我自己的答案,简单 我只是像

在hexkbd

所有的XML文件中添加一个相同的按钮:在关键标签

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

在hexkbd2

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

和CustomKeyboard类KeyboardActionListener decalare:

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

和CustomKeyboard类安其()事件:

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

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

     } else if (primaryCode == ChangeKey2) { 

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

     } 

完成的,它简单,但我的困惑需要时间,我分享我的想法,以帮助其他我认为这对他人有帮助。