I want to save the keycode of the first key pressed after the button
is clicked.

On 22 okt, 05:19, Lance Nanek <[email protected]> wrote:
> There are some focus related methods on the View class: requestFocus,
> setFocusable, setFocusableInTouchMode. In this case arg0 is the button
> that was clicked, though. It seems odd to listen for key presses when
> a button is focused. Are you sure you don't want to listen for key
> presses on some view higher up the chain?
>
> On Oct 21, 10:16 am,Bolletje<[email protected]> wrote:
>
> > I got stuck a few days ago and I don't seem to make any headway so
> > hopefully someone can help me.
>
> > I want to set a key in my settings after the click of a button, but I
> > can't add a keylistener to the View.OnClickListener or to the View
> > arg0. Then I made it like this:
>
> > bUP2.setOnClickListener(new View.OnClickListener() {
> >           public void onClick(View arg0) {
> >                         Toast.makeText(Keyinput.this, "Give key Player 2 
> > UP",
> > Toast.LENGTH_LONG).show();
> >                         View.OnKeyListener vok = new View.OnKeyListener() {
> >                         public boolean onKey(View v, int keyCode, KeyEvent 
> > event) {
> >                                         
> > System.out.println("------------------> onKey "+keyCode);
> >                                         editor.putInt("UP2", keyCode);
> >                                         editor.commit();
> >                                         return true;
> >                                 }
> >                          };
> >                         arg0.setOnKeyListener(vok);
> >           }
>
> > });
>
> > Do I have to focus to the new View somehow? Or is there a simpeler
> > solution?
>
> > Thanks in advance.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to