728x90

 

//EditText 객체에서 onKeyPreIme 메소드를 재정의

    public boolean onKeyPreIme( int keyCode, KeyEvent event ) {
     
   
     Log.d("AutoCallService", "keyCode : "+keyCode+"");
     Log.d("AutoCallService", "event.getKeyCode() : "+event.getKeyCode()+"");
     switch (event.getAction()) {
     
     case KeyEvent.ACTION_DOWN :
     
     if( event.getAction() == KeyEvent.ACTION_DOWN ) {
     if( keyCode == KeyEvent.KEYCODE_BACK ) {
     this.clearFocus();
     

     Log.d("AutoCallService", "onBackPressed()2");
     }
     }
     break;
     
     
     }
   
return super.onKeyPreIme( keyCode, event );
}

Activity 에서 implements OnEditorActionListener 후


/*@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {

if(event.getAction() == KeyEvent.ACTION_DOWN)
{
Log.i("AutoCallService", event.getKeyCode()+"");

}
// TODO Auto-generated method stub
return false;
}*/

 

Reference

http://nerobong2.blogspot.com/2015/12/androidedittext.html

728x90

+ Recent posts