有什么方法可以捕捉事件吗?
我的意思是当我单击编辑框内部时,会出现软键盘。
软键盘出现回调函数。是否可以?
//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);
...........