2

こんにちは私はこのアプリでアプリケーションを作成したいユーザーはコンピュータのedrawソフトウェアのようなドラッグアンドドロップ画像を介してフローチャートを作成します事前にこのThansを実装する方法を教えてください

4

1 に答える 1

2

サンプル:

private void dragImage() {
    imgLogo.setOnLongClickListener(new
            OnLongClickListener() {
                @Override
                public boolean onLongClick(View v) {
                    // ClipData data = ClipData.newPlainText("dot",
                    // "Dot : " + v.toString());
                    ClipData data = ClipData
                            .newPlainText("dot",
                                    "Oops!\r\nWe are pleased that we have such clever customers! ;)");

                    MyDragShadowBuilder myShadow = new MyDragShadowBuilder(
                            v);
                    v.startDrag(data, myShadow, (Object) v, 0);

                    return false;
                }
            });
    imgLogo.setClickable(true);
    imgLogo.setFocusable(true);
    imgLogo.setOnDragListener(new OnDragListener() {
        @Override
        public boolean onDrag(View v, DragEvent event) {
            final int action = event.getAction();

            // if (myShadow != null)
            // myShadow.setCurrentPosition(event.getX(), event.getY());
            switch (action) {
            case DragEvent.ACTION_DRAG_STARTED: {
                imgLogo.setVisibility(View.INVISIBLE);
            }
                break;
            case DragEvent.ACTION_DRAG_ENDED: {
                // Hide the surprise again
                imgLogo.setVisibility(View.VISIBLE);

                // Report the drop/no-drop result to the user
                final boolean dropped = event.getResult();
                // tvGalleryLblQty.setText("ended");
            }
                break;
            case DragEvent.ACTION_DROP: {
                final boolean dropped = event.getResult();
            }
                break;
            }
            return false;
        }
    });
}
于 2012-05-09T07:18:49.987 に答える