0

私はチャートに取り組んでいます。ズームイン、アウト、ドラッグできます...また、ドラッグでロングクリックする必要があります。説明が必要な場合、ユーザーはロングクリックしてチャートの値を表示できます。また、ユーザーはロングクリックで左、右にドラッグして他の値を表示できます...Androidはそれを感知できますか? achartengine ライブラリを使用します。

私は今それを扱うことができます:)しかし、私は別の問題を抱えています..

 longPressDetector = new GestureDetector(getContext(), new SimpleOnGestureListener() {
     @Override
     public void onLongPress(final MotionEvent e) {
        int x = (int) e.getX();
        final int y = (int) e.getY();
        Toast.makeText(context, "long press", Toast.LENGTH_SHORT).show();
        }
       });

しかし、コードは私が理解しているわけではありません。何を知ればいいの??

   @Override
  public boolean onTouchEvent(MotionEvent event) {
  if (longPressDetector.onTouchEvent(event)) {
      return true; *** not work.
  }

そして、このように longClick でドラッグできますか?? 私は正しいですか?

4

1 に答える 1

1

OK、これを使います。

   longPressDetector = new GestureDetector(getContext(),
            new SimpleOnGestureListener() {
                @Override
                public void onLongPress(final MotionEvent e) {
                    if (!isVolumeChart) {
                        touchHandler.handleLongTouch(true);
                        onLongPress = true;
                    }
                }

                @Override
                public boolean onSingleTapUp(MotionEvent e) {
                    if (!isVolumeChart && onClickLayout != null)
                        onClickLayout.onClickedView(rootLayout);
                    return super.onSingleTapUp(e);
                }

                @Override
                public boolean onDoubleTap(MotionEvent e) {
                    if (!isVolumeChart) {
                        fitZoom = new FitZoom(mChart);
                        zoomReset();
                        if (volumeView != null) {
                            volumeView.fitZoom = new FitZoom(
                                    volumeView.mChart);
                            volumeView.zoomReset();
                        }
                    }
                    return super.onDoubleTap(e);
                }
            });
于 2011-10-11T12:25:54.293 に答える