aspose file tools*
The moose likes Android and the fly likes help with simple keyboardview test Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Android
Bookmark "help with simple keyboardview test" Watch "help with simple keyboardview test" New topic
Author

help with simple keyboardview test

Peter Hudson
Greenhorn

Joined: Feb 12, 2011
Posts: 4
Hi All,

I'm Android newbie. I've done some of the tutorials, explored the SDK softkeyboard example and the "smallkeyboard" class that Chris Boyle shared. Now I'm trying to test a simple KeyboardView that later I will make do something. I can't seem to get it to to work. The emulator says the app stopped unexpectedly (before a keyboard is displayed) and forces close. Can anyone see what I'm missing?

here's the code:





Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42641
    
  65
If an app crashes there will be an exception stacktrace in the log output. You can use adb logcat to look at it; that'll give you (and us) clues as to what's going wrong.


Ping & DNS - my free Android networking tools app
Peter Hudson
Greenhorn

Joined: Feb 12, 2011
Posts: 4
Hi Ulf,

I think this is the relevant output from logcat...Does this help?

-Peter-

02-13 09:25:33.239: ERROR/AndroidRuntime(227): Uncaught handler: thread main exiting due to uncaught exception
02-13 09:25:33.279: ERROR/AndroidRuntime(227): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.peter.testkeys/com.peter.testkeys.TestKey}: android.view.InflateException: Binary XML file line #13: Error inflating class KeyBoardView
02-13 09:25:33.279: ERROR/AndroidRuntime(227): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
02-13 09:25:33.279: ERROR/AndroidRuntime(227): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
02-13 09:25:33.279: ERROR/AndroidRuntime(227): at android.app.ActivityThread.access$2200(ActivityThread.java:119)
02-13 09:25:33.279: ERROR/AndroidRuntime(227): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
02-13 09:25:33.279: ERROR/AndroidRuntime(227): at android.os.Handler.dispatchMessage(Handler.java:99)
02-13 09:25:33.279: ERROR/AndroidRuntime(227): at android.os.Looper.loop(Looper.java:123)
02-13 09:25:33.279: ERROR/AndroidRuntime(227): at android.app.ActivityThread.main(ActivityThread.java:4363)
02-13 09:25:33.279: ERROR/AndroidRuntime(227): at java.lang.reflect.Method.invokeNative(Native Method)
02-13 09:25:33.279: ERROR/AndroidRuntime(227): at java.lang.reflect.Method.invoke(Method.java:521)
02-13 09:25:33.279: ERROR/AndroidRuntime(227): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
02-13 09:25:33.279: ERROR/AndroidRuntime(227): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
02-13 09:25:33.279: ERROR/AndroidRuntime(227): at dalvik.system.NativeStart.main(Native Method)
02-13 09:25:33.279: ERROR/AndroidRuntime(227): Caused by: android.view.InflateException: Binary XML file line #13: Error inflating class KeyBoardView
02-13 09:25:33.279: ERROR/AndroidRuntime(227): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:576)
02-13 09:25:33.279: ERROR/AndroidRuntime(227): at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
02-13 09:25:33.279: ERROR/AndroidRuntime(227): at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
02-13 09:25:33.279: ERROR/AndroidRuntime(227): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
02-13 09:25:33.279: ERROR/AndroidRuntime(227): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
02-13 09:25:33.279: ERROR/AndroidRuntime(227): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
02-13 09:25:33.279: ERROR/AndroidRuntime(227): at android.app.Activity.setContentView(Activity.java:1622)
02-13 09:25:33.279: ERROR/AndroidRuntime(227): at com.peter.testkeys.TestKey.onCreate(TestKey.java:24)
02-13 09:25:33.279: ERROR/AndroidRuntime(227): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
02-13 09:25:33.279: ERROR/AndroidRuntime(227): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
02-13 09:25:33.279: ERROR/AndroidRuntime(227): ... 11 more
02-13 09:25:33.279: ERROR/AndroidRuntime(227): Caused by: java.lang.ClassNotFoundException: android.view.KeyBoardView in loader dalvik.system.PathClassLoader@43d0b820
02-13 09:25:33.279: ERROR/AndroidRuntime(227): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
02-13 09:25:33.279: ERROR/AndroidRuntime(227): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
02-13 09:25:33.279: ERROR/AndroidRuntime(227): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
02-13 09:25:33.279: ERROR/AndroidRuntime(227): at android.view.LayoutInflater.createView(LayoutInflater.java:466)
02-13 09:25:33.279: ERROR/AndroidRuntime(227): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:544)
02-13 09:25:33.279: ERROR/AndroidRuntime(227): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66)
02-13 09:25:33.279: ERROR/AndroidRuntime(227): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
02-13 09:25:33.279: ERROR/AndroidRuntime(227): ... 20 more
02-13 09:25:33.309: INFO/Process(59): Sending signal. PID: 227 SIG: 3
02-13 09:25:33.309: INFO/dalvikvm(227): threadid=7: reacting to signal 3
02-13 09:25:33.519: INFO/ARMAssembler(59): generated scanline__00000177:03515104_00001001_00000000 [ 91 ipp] (114 ins) at [0x4a4a60:0x4a4c28] in 791861 ns
02-13 09:25:33.719: DEBUG/Eas Debug(206): Logging:
02-13 09:25:33.790: DEBUG/EAS SyncManager(206): !!! EAS SyncManager, onDestroy
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42641
    
  65
Yup, that helps. These are the important ones:
android.view.InflateException: Binary XML file line #13: Error inflating class KeyBoardView

That tells you that an error occurred during processing of one of the XML files, specifically something about the KeyBoardView class is wrong.

Caused by: java.lang.ClassNotFoundException: android.view.KeyBoardView

And this tells you what's wrong with the class: Android doesn't know it ("can't find it", in Java terms). And indeed, the android.view package has no such class. There is a class with a similar name in a different package, though, which I assume you meant. Figuring out the right package and the right class name is left as an exercise to the reader :-)
Peter Hudson
Greenhorn

Joined: Feb 12, 2011
Posts: 4
So Let's see,

I know when I included the class it was with "import android.inputmethodservice.KeyboardView;"
when I create it with "myKeyboardView = (KeyboardView)findViewById(R.id.myKeyboardViewXML); "
I must be indirectly trying to cast a view class result as an inputmethodservice.keyboardView object.
Am I close?

I tried this one once to no avail.

myKeyboardView = (KeyboardView) getLayoutInflater().inflate(R.id.myKeyboardViewXML, null);

are there other/better ways to construct the keyboardview object?

I'm working towards a keyboard that is always up on the screen and used as an input. I don't want to create a keyboard service.
I was basing my approach on the following advice I found on some other forums.


Keyboard/KeyboardView is just a view. It is often used for writing the UI
of an input method, but you can use it to write any UI.
To use it in your app, you just need to incorporate it into your UI
appropriately. No just throwing it into your XML will probably not work.
If you want to show it and hide it, you will need to decide how you want
this to interact with the rest of the UI. For example you could put it in a
Dialog that you set up without a frame (there are API demos showing how to
customize Dialog visuals), and make a window animation to have it slide up
from the bottom of the screen when it is displayed. What exactly to do with
the view is up to you.


Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42641
    
  65
The problem isn't with the code, or you'd be getting a compilation error. The problem is in one of the XML files.

I have no particular knowledge of keyboards or keyboard layouts, so I can't help with the actual issue you're trying to address.
Peter Hudson
Greenhorn

Joined: Feb 12, 2011
Posts: 4
You've helped some and at least I'm moving forward; I'll explore the XML more deeply. Meanwhile if anyone else has some tips I'm all ears!

Chaitali Diwan
Greenhorn

Joined: Dec 18, 2011
Posts: 1
Peter Hudson wrote:You've helped some and at least I'm moving forward; I'll explore the XML more deeply. Meanwhile if anyone else has some tips I'm all ears!



Hi Peter, Did you find the solution to this one? I have the same issue, Can you please post your solution if you found one.
Thanks!!
David Singleton
Greenhorn

Joined: Jan 29, 2012
Posts: 1
I had a very similar problem. I was using inflate() to load the KeyboardView, because other methods did not seem to be working. I was getting an error in the logcat output file: android.view.InflateException: Binary XML file line #2: Error inflating class KeyboardView. After some more research in the Android documentation, I found a section on custom views. There I found an example with a class LabelView. The XML resource file contained a fully qualified name for the class. I tried this with KeyboardView, entering <android.inputmethodservice.KeyboardView> in my layout file. My code now loaded without error!
Hussein Baghdadi
clojure forum advocate
Bartender

Joined: Nov 08, 2003
Posts: 3479

Hi David and welcome to the Ranch
Kindly check your JavaRanch's inbox for an important administrative issue.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: help with simple keyboardview test