• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

help with simple keyboardview test

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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:





 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Peter Hudson
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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!!
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
clojure forum advocate
Posts: 3479
Mac Objective C Clojure
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi David and welcome to the Ranch
Kindly check your JavaRanch's inbox for an important administrative issue.
 
Where all the women are strong, all the men are good looking and all the tiny ads are above average:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic