0

Are there any ways to catch an event?

I mean when i click inside of edit box and then soft keyboard will appear.

soft keyboard appears with callback function. Is it possible?

Soonho Hong
  • 37
  • 1
  • 6

1 Answers1

3
//Clicking on the text box     

   edittext.setOnClickListener(new OnClickListener(){
        public void onClick(View v) {
        InputMethodManager imm = (InputMethodManager) getSystemService(
                INPUT_METHOD_SERVICE);
        imm.showSoftInput(getCurrentFocus().getWindowToken(), //some flag here);
        }

   });

     //Being inside the box and pressing a key
     edittext.setOnKeyListener(new OnKeyListener() {
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            //If the event is a key-down event on the "enter" button
            //If enter is pressed while inside the textbox
            if ((event.getAction() == KeyEvent.ACTION_DOWN) &&
                (keyCode == KeyEvent.KEYCODE_ENTER)) {

                    InputMethodManager imm = (InputMethodManager) getSystemService(
                        INPUT_METHOD_SERVICE);
                    //Example of hiding keyboard inside enter pressed check
                    imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);

........

krilovich
  • 3,475
  • 1
  • 23
  • 33