0
저는 새로운 Android 개발자입니다. 나는 터치 이벤트를 다루기 위해 서비스를 사용하고 싶다. 코드는 doTouch() 일 뿐이며, "만져라"는 것을 의미한다. 내가 "아래로", "POINTER_DOWN", "시작하다"를 보여주고 싶다면 어떻게해야합니까? 그것? 어떤 도움? 미리 감사드립니다! logcat과 콘솔에 아무런 이상이 없습니다.서비스를 사용하여 터치 이벤트를 처리 할 수 있습니까?
public class MainService extends Service {
private ViewService mViewService = null;
@Override
public IBinder onBind(Intent arg0) {
// TODO Auto-generated method stub
return null;
}
@Override
public void onCreate(){
super.onCreate();
startForeground(1, new Notification());
mViewService = ViewService.getInstance(this);
mViewService.addView(ViewService.TOUCH_VIEW);
mViewService.getView(ViewService.TOUCH_VIEW).setOnTouchListener(new TouchListener());
}
//do touch event
public void doTouch(){
Toast.makeText(this, "touched", Toast.LENGTH_SHORT).show();
}
class TouchListener implements View.OnTouchListener{
@Override
public boolean onTouch(View v, MotionEvent e) {
// TODO Auto-generated method stub
if(e.getAction() == MotionEvent.ACTION_OUTSIDE){
MainService.this.doTouch();
//Toast.makeText(getBaseContext(), "TOUED", Toast.LENGTH_SHORT).show();
}
/*else if(e.getAction() == MotionEvent.ACTION_DOWN){
MainService.this.doTouch();
}*/
/*if(e.getPointerCount() >= 3){
MainService.this.doTouch();
}*/
switch (e.getAction()) {
case MotionEvent.ACTION_DOWN:
Toast.makeText(getBaseContext(), "DOWN", Toast.LENGTH_SHORT).show();
break;
case MotionEvent.ACTION_POINTER_DOWN:
if(e.getPointerCount() >= 3){
Toast.makeText(getBaseContext(), "POINTER_DOWN", Toast.LENGTH_SHORT).show();
}
case MotionEvent.ACTION_MOVE:
Toast.makeText(getBaseContext(), "BEGIN", Toast.LENGTH_SHORT).show();
break;
default:
break;
}
return true;
}
}
}
당신은 더 구체적인 수 있을까? 오류가 있습니까? http://stackoverflow.com/help/how-to-ask –
이 서비스에서 멀티 터치하는 방법은 무엇입니까? –
여기 링크 [link] http://stackoverflow.com/questions/25661708/ 핸들 - 멀티 - 터치 이벤트를 사용할 수 있습니다. [link] –