Android学习笔记基于回调的事件处理

流程:

Android学习笔记基于回调的事件处理

常见的回调方法:

Android学习笔记基于回调的事件处理

代码示例:

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        Toast.makeText(getApplicationContext(),"触摸",Toast.LENGTH_SHORT).show();
        return super.onTouchEvent(event);
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        Toast.makeText(getApplicationContext(),"按下",Toast.LENGTH_SHORT).show();
        return super.onKeyDown(keyCode, event);
    }

    @Override
    public boolean onKeyUp(int keyCode, KeyEvent event) {
        Toast.makeText(getApplicationContext(),"抬起",Toast.LENGTH_SHORT).show();
        return super.onKeyUp(keyCode, event);
    }

Android学习笔记基于回调的事件处理

上一篇:android Fatal signal 4 (SIGILL), code 1, fault addr 0xa455075e in tid 28272 (GLThread 3467)


下一篇:ionic cordova 打包的app图片尺寸