我正在研究 android 中的自定义键盘实现。到目前为止,我已经在一个 xml 文件中声明了我的键盘布局:
<android.inputmethodservice.Keyboard.Row>
<Key android:codes="113" android:keyLabel="q" android:keyEdgeFlags="left"/>
<Key android:codes="119" android:keyLabel="w"/>
<Key android:codes="101" android:keyLabel="e"/>
<Key android:codes="114" android:keyLabel="r"/>
<Key android:codes="116" android:keyLabel="t"/>
<Key android:codes="121" android:keyLabel="y"/>
<Key android:codes="117" android:keyLabel="u"/>
<Key android:codes="105" android:keyLabel="i"/>
<Key android:codes="111" android:keyLabel="o"/>
<Key android:codes="112" android:keyLabel="p" android:keyEdgeFlags="right"/>
</android.inputmethodservice.Keyboard.Row>
当我尝试扩展此布局时,出现以下错误:
E/AndroidRuntime( 4775): FATAL EXCEPTION: main
E/AndroidRuntime( 4775): android.view.InflateException: Binary XML file line #9: Error inflating class android.inputmethodservice.Keyboard.Row
E/AndroidRuntime( 4775): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:581)
E/AndroidRuntime( 4775): at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
E/AndroidRuntime( 4775): at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
E/AndroidRuntime( 4775): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
E/AndroidRuntime( 4775): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
E/AndroidRuntime( 4775): at com.mykeyboard.MyKeyboardService.onCreateInputView(MyKeyboardService.java:23)
E/AndroidRuntime( 4775): at android.inputmethodservice.InputMethodService.updateInputViewShown(InputMethodService.java:967)
E/AndroidRuntime( 4775): at android.inputmethodservice.InputMethodService.showWindowInner(InputMethodService.java:1320)
E/AndroidRuntime( 4775): at android.inputmethodservice.InputMethodService.showWindow(InputMethodService.java:1295)
E/AndroidRuntime( 4775): at android.inputmethodservice.InputMethodService$InputMethodImpl.showSoftInput(InputMethodService.java:398)
E/AndroidRuntime( 4775): at android.inputmethodservice.IInputMethodWrapper.executeMessage(IInputMethodWrapper.java:176)
E/AndroidRuntime( 4775): at com.android.internal.os.HandlerCaller$MyHandler.handleMessage(HandlerCaller.java:61)
E/AndroidRuntime( 4775): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 4775): at android.os.Looper.loop(Looper.java:130)
E/AndroidRuntime( 4775): at android.app.ActivityThread.main(ActivityThread.java:3703)
E/AndroidRuntime( 4775): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 4775): at java.lang.reflect.Method.invoke(Method.java:507)
E/AndroidRuntime( 4775): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
E/AndroidRuntime( 4775): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
E/AndroidRuntime( 4775): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 4775): Caused by: java.lang.ClassNotFoundException: android.inputmethodservice.Keyboard.Row in loader dalvik.system.PathClassLoader[/data/app/com.mykeyboard-2.apk]
E/AndroidRuntime( 4775): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
E/AndroidRuntime( 4775): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
E/AndroidRuntime( 4775): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
E/AndroidRuntime( 4775): at android.view.LayoutInflater.createView(LayoutInflater.java:471)
E/AndroidRuntime( 4775): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:570)
E/AndroidRuntime( 4775): ... 19 more
貌似找不到android.inputmethodservice.Keyboard.Row in loader dalvik.system.PathClassLoader
,但这是什么意思?
有什么建议么?