[英]Define key combination to perform an action in android
In android, how can I define a key combination in app to perform some action? 在android中,如何在应用中定义按键组合以执行某些操作?
For example, if user press e
and x
letters on a keyboard at the same time, how can I assign a special task to do when this event is fired? 例如,如果用户同时按下键盘上的e
和x
字母,那么在触发此事件时如何分配特殊任务来执行?
public boolean onTouchEvent(MotionEvent event) {
int x = (int)event.getX();
int y = (int)event.getY();
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
case MotionEvent.ACTION_MOVE:
case MotionEvent.ACTION_UP:}
return false;}
From this you would get the postion of yout touch.Now do some logic on setOnClickListner of other button or "x" here. 由此,您将获得触摸的位置。现在,在此处对其他按钮或“ x”的setOnClickListner进行一些逻辑处理。
Hope it helps. 希望能帮助到你。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.