android in drag'n'drop ,img can be drag ,but not drop
<p>I'm doing lots of stuff but i can't get.The problem which i face is when i drag the image its work ok and when i drop it it can't replace or can't see,
below i have put my code please help where i am wrong.</p>

<p>public class MainActivity extends Activity {</p>

<pre><code>TextView comments;
ImageView img, buttonTarget;

String commentMsg;

MyDragEventListener myDragEventListener = new MyDragEventListener();

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    img = (ImageView) findViewById(R.id.ivImg);

    buttonTarget = (ImageView) findViewById(R.id.buttonTarget);

    // Create and set the tags for the Buttons
    final String IMG_TAG = "img";

    img.setTag(IMG_TAG);

    img.setOnLongClickListener(sourceimgLongClickListener);

    img.setOnDragListener(myDragEventListener);
    buttonTarget.setOnDragListener(myDragEventListener);
}

ImageView.OnLongClickListener sourceimgLongClickListener = new ImageView.OnLongClickListener() {

    @Override
    public boolean onLongClick(View v) {
        ClipData.Item item = new ClipData.Item((CharSequence) v.getTag());

        String[] clipDescription = { ClipDescription.MIMETYPE_TEXT_PLAIN };
        ClipData dragData = new ClipData((CharSequence) v.getTag(),
                clipDescription, item);
        DragShadowBuilder myShadow = new MyDragShadowBuilder(v);

        v.startDrag(dragData, myShadow, v, 0);

        return true;
    }
};

private static class MyDragShadowBuilder extends View.DragShadowBuilder {
    // private static Drawable shadow;

    public MyDragShadowBuilder(View v) {
        super(v);
        // shadow = new ColorDrawable(Color.LTGRAY);
    }

    @Override
    public void onProvideShadowMetrics(Point size, Point touch) {
        int width = getView().getWidth();
        int height = getView().getHeight();
        // Log.i("metrix",""+width+"  "+height);
        // shadow.setBounds(0, 0, width, height);
        size.set(width, height);
        touch.set(width / 2, height / 2);
        // Log.i("metrix",""+width/5+"  "+height/5);
    }

    /*
     * @Override public void onDrawShadow(Canvas canvas) {
     * shadow.draw(canvas); }
     */

}

protected class MyDragEventListener implements View.OnDragListener {

    @SuppressWarnings("deprecation")
    @Override
    public boolean onDrag(View v, DragEvent event) {
        final int action = event.getAction();

        switch (action) {
        case DragEvent.ACTION_DRAG_STARTED:
            Log.i("action", "start");
            // All involved view accept ACTION_DRAG_STARTED for
            // MIMETYPE_TEXT_PLAIN

            if (event.getClipDescription().hasMimeType(
                    ClipDescription.MIMETYPE_TEXT_PLAIN)) {
                return true; // Accept
            } else {
                return false; // reject
            }

        case DragEvent.ACTION_DRAG_ENTERED:
            Log.i("action", "entered");

            return true;
        case DragEvent.ACTION_DRAG_LOCATION:
            Log.i("action", "location");

            return true;
        case DragEvent.ACTION_DRAG_EXITED:
            Log.i("action", "exited");

            return true;
        case DragEvent.ACTION_DROP:
            Log.i("action", "drop");
            // Gets the item containing the dragged data
            // ClipData.Item item = event.getClipData().getItemAt(0);

            // If apply only if drop on buttonTarget
            if (v == buttonTarget) {

                // Retrieve the source view using getLocalState()
                View dragView = (View) event.getLocalState();

                ((ImageView) v)
                        .setBackgroundDrawable(((ImageView) dragView)
                                .getBackground());
            }

            return true;
        case DragEvent.ACTION_DRAG_ENDED:
            Log.i("action", "ended");
            if (event.getResult()) {
            } else {
            }

            return true;
        default: // unknown case
            return false;

        }
    }
}
</code></pre>

<p>}</p>

<p>so the above is my code please check it and suggestion me thanks.</p>