这是我的资源文件 res/layout/input.xml。My.application - 我的 android 程序的名称
<my.application.android.inputmethodservice.KeyboardView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/keyboard"
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
Android软键盘在此创建:
public View onCreateInputView() {
mInputView = (KeyboardView) getLayoutInflater().inflate(R.layout.input,
null);
Keyboard keyboard = new Keyboard(this, R.xml.qwerty);
mInputView.setKeyboard(keyboard);
mInputView.setEnabled(true);
mInputView.setPreviewEnabled(true);
mInputView.setOnKeyboardActionListener(this);
return mInputView;
}
应用程序编译没有错误。当我在任何 android 应用程序中调用我的软键盘时,我得到下一个错误:
12-12 09:07:39.183: E/AndroidRuntime(25341): FATAL EXCEPTION: main
12-12 09:07:39.183: E/AndroidRuntime(25341): android.view.InflateException: Binary XML file line #21: Error inflating class my.application.android.inputmethodservice.KeyboardView
12-12 09:07:39.183: E/AndroidRuntime(25341): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:698)
12-12 09:07:39.183: E/AndroidRuntime(25341): at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
12-12 09:07:39.183: E/AndroidRuntime(25341): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
12-12 09:07:39.183: E/AndroidRuntime(25341): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
12-12 09:07:39.183: E/AndroidRuntime(25341): at application.my.Keyb.onCreateInputView(Keyb.java:59)
12-12 09:07:39.183: E/AndroidRuntime(25341): at android.inputmethodservice.InputMethodService.updateInputViewShown(InputMethodService.java:1073)
12-12 09:07:39.183: E/AndroidRuntime(25341): at android.inputmethodservice.InputMethodService.showWindowInner(InputMethodService.java:1428)
12-12 09:07:39.183: E/AndroidRuntime(25341): at android.inputmethodservice.InputMethodService.showWindow(InputMethodService.java:1403)
12-12 09:07:39.183: E/AndroidRuntime(25341): at android.inputmethodservice.InputMethodService$InputMethodImpl.showSoftInput(InputMethodService.java:424)
12-12 09:07:39.183: E/AndroidRuntime(25341): at android.inputmethodservice.IInputMethodWrapper.executeMessage(IInputMethodWrapper.java:188)
12-12 09:07:39.183: E/AndroidRuntime(25341): at com.android.internal.os.HandlerCaller$MyHandler.handleMessage(HandlerCaller.java:40)
12-12 09:07:39.183: E/AndroidRuntime(25341): at android.os.Handler.dispatchMessage(Handler.java:99)
12-12 09:07:39.183: E/AndroidRuntime(25341): at android.os.Looper.loop(Looper.java:137)
12-12 09:07:39.183: E/AndroidRuntime(25341): at android.app.ActivityThread.main(ActivityThread.java:5039)
12-12 09:07:39.183: E/AndroidRuntime(25341): at java.lang.reflect.Method.invokeNative(Native Method)
12-12 09:07:39.183: E/AndroidRuntime(25341): at java.lang.reflect.Method.invoke(Method.java:511)
12-12 09:07:39.183: E/AndroidRuntime(25341): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
12-12 09:07:39.183: E/AndroidRuntime(25341): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
12-12 09:07:39.183: E/AndroidRuntime(25341): at dalvik.system.NativeStart.main(Native Method)
12-12 09:07:39.183: E/AndroidRuntime(25341): Caused by: java.lang.ClassNotFoundException: Didn't find class "my.application.android.inputmethodservice.KeyboardView" on path: /data/app/application.my-1.apk
12-12 09:07:39.183: E/AndroidRuntime(25341): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
12-12 09:07:39.183: E/AndroidRuntime(25341): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
12-12 09:07:39.183: E/AndroidRuntime(25341): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
12-12 09:07:39.183: E/AndroidRuntime(25341): at android.view.LayoutInflater.createView(LayoutInflater.java:552)
12-12 09:07:39.183: E/AndroidRuntime(25341): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)
12-12 09:07:39.183: E/AndroidRuntime(25341): ... 18 more