I'm relatively new to android and I'm working on a horizontal scroll view with drag and drop functionality. Right now everything is working perfectly fine I can drag the image and drop it in the drop zone with count of failed and successful drops. For now the image that is being dragged and its shadow looks the same. What I want is that when I drag an image the shadow that appears for that image is an image from drawables that I select.
Here is the code for shadow builder:
void dragAndDropImage(int imageId)
{
// int drawableid = getResources().getIdentifier("drawable/a1", "id", getPackageName());
final ImageView drag = (ImageView)findViewById(imageId);
drag.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent arg1) {
// TODO Auto-generated method stub
ClipData data = ClipData.newPlainText("", "");
View.DragShadowBuilder shadow = new View.DragShadowBuilder(drag);//I want the drawable id here View.DragShadowBuilder(drawableid)
v.startDrag(data, shadow, null, 0);
return false;
}
});
I want to get the id of one particular image from drawables and then I can use it in View.DragShadowBuilder(id of the image from drawables) to change the image of the shadow. Any help in this regard is appreciated.