I have a fragment class, in the fragment class, I implement the
onCreateView(...) callback in the following way:

********************************************************************************************************************
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {

         View myView = inflater.inflate(R.layout.note, null);

        myView.setOnKeyListener(
                new OnKeyListener(){
                        @Override
                        public boolean onKey( View v, int keyCode, KeyEvent 
event ){

                                        if( keyCode == KeyEvent.KEYCODE_BACK ){
                                                Log.v("CALL ME", "I am called");
                                                return true;
                                         }
                                        return false;
                         }
        });

      return myView;
}

***************************************************************************************************************
As you see above, I inflate a layout to this fragment, then I
setOnKeyListener() to handle the back button press event. But when I
run it on my phone, the back button press event is not handled, my Log
message is not showing. Why my OnKeyListener is not working ???

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to