That's strange, I posted a reply but my message did not appear. Sorry if I end up double-posting.
Try adding setFocusableInTouchMode(true) in addition to setFocusable (true). Also, your onKey callback looks incomplete, it should look more like this: @Override public boolean onKeyDown(int keyCode, KeyEvent event) {...} @Override public boolean onKeyUp(int keyCode, KeyEvent event) {...} On Jan 15, 10:21 am, guich <guiha...@gmail.com> wrote: > Hi, > > I have this View: > > public class Launcher4A extends SurfaceView implements > SurfaceHolder.Callback, OnKeyListener > { > public Launcher4A(Context context) > { > super(context); > System.loadLibrary("tcvm"); > instance = this; > surfHolder = getHolder(); > surfHolder.addCallback(this); > setWillNotDraw(true); > setFocusable(true); > requestFocus(); > setOnKeyListener(this); > } > > public boolean onKey(View v, int keyCode, KeyEvent event) > { > Log.i("TotalCross", "onKeyDown "+keyCode); > return true; > } > > } > > When i run the application in Emulator, the onKey is never called if > the Launcher4A class was clicked inside. Actually, i was able to get > the onKeyDown log once, when i clicked somewhere outside the view, but > i'm unable to get it when the view has focus. > > Am I missing something? > > Best, > > guich
-- You received this message because you are subscribed to the Google Groups "Android Beginners" group. NEW! Try asking and tagging your question on Stack Overflow at http://stackoverflow.com/questions/tagged/android To unsubscribe from this group, send email to android-beginners+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-beginners?hl=en