Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6185207
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:40:19+00:00 2026-05-24T01:40:19+00:00

Hii all m trying to implement Drag and Drop in 3.0.i have gone through

  • 0

Hii all m trying to implement Drag and Drop in 3.0.i have gone through the example given in developers site,but m facing a problem while dropping.Here is my code,m able to drag the image view,but not able to drop it.could any one plz tell me what is the problem or provide any sample code??

    setContentView(R.layout.main);
    iv=(ImageView)findViewById(R.id.iv);
    lv=(RelativeLayout)findViewById(R.id.lv);
    lv.setOnDragListener(this);
    iv.setTag("HELLOOO");
    iv.setOnLongClickListener(this);   
}
      public boolean onDrag(View v, DragEvent event) {
    CharSequence dragData;
    switch(event.getAction()){
    case DragEvent.ACTION_DRAG_STARTED:
        break;
    case DragEvent.ACTION_DRAG_ENTERED:
        insideOfMe = true;
        break;
    case DragEvent.ACTION_DRAG_LOCATION:
        break;
    case DragEvent.ACTION_DRAG_ENDED:
        break;
    case DragEvent.ACTION_DRAG_EXITED:
        insideOfMe = false;
        break;
    case DragEvent.ACTION_DROP:
        break;
    }

    return true;
}
public static class Shadow extends View.DragShadowBuilder{
    Drawable d;
    public Shadow(View v,Context context){
        super(v);
    d=context.getResources().getDrawable(R.drawable.icon);
    }

    @Override
    public void onProvideShadowMetrics(Point shadowSize,
            Point shadowTouchPoint) {
        // TODO Auto-generated method stub
                    int width,height;
                   width=getView().getWidth();
                    height=getView().getHeight();
                   d.setBounds(0,0,width,height);
                 shadowSize.set(width, height);
                 shadowTouchPoint.set(width/2, height/2);   
    }
    public void onDrawShadow(Canvas canvas){
canvas.save();
d.draw(canvas);
canvas.restore();
    }
    }  
public boolean onLongClick(View v) {
     ClipData.Item item = new ClipData.Item((CharSequence) v.getTag());
        ClipDescription NOTE_STREAM_TYPES = new ClipDescription( (CharSequence)                                           

     v.getTag(),new String[] { ClipDescription.MIMETYPE_TEXT_PLAIN });
 ClipData data = new ClipData(NOTE_STREAM_TYPES, item);

     shadow=new Shadow(v,getApplicationContext());

     v.startDrag(data, shadow,null,0);

    return false;
}

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T01:40:20+00:00Added an answer on May 24, 2026 at 1:40 am

    You have not implemented any functionality for DragEvent.ACTION_DROP

    In this case you can do:

        case DragEvent.ACTION_DROP:
            if (insideOfMe) {
                Item item = event.getClipData().getItemAt(0);
                // Do whatever you want to do with the item
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Edit Ok I solved all my problems but one. Is it possible to have
Hi i am trying to set up an RSA cryptosystem i have all the
Hi I am trying to implement hasPathSum() means for given number is there any
Hi I'm trying to read all files from a given server. What I want
Hi i have a small problem, first of all im trying to run a
hi i am trying to add undo feature to finger paint example given in
Hii all, I am trying to downaload large file in rails using send_data function
Hi I am trying to find all js & css files in one find
Hi I have a plugin.dll which contains this all npp functions I have embeded
Hi I have a query in PHP that calculates the sum of all the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.