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 8969901
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:39:32+00:00 2026-06-15T17:39:32+00:00

I want to implement two different Drag and Drop interactions with one Button. If

  • 0

I want to implement two different Drag and Drop interactions with one Button. If the user clicks long on the Button, he can move the button. This is no Problem, I implemented OnLongClickListener:

@Override
public boolean onLongClick(View v) {
    ClipData dragData = ClipData.newPlainText(
            AbstractFragment.BUTTON_ID_TAG, "" + v.getId());
    DragShadowBuilder shadow = new DragShadowBuilder(v);
    v.startDrag(dragData, shadow, null, 0);
    return true;
}

If the user touches the Button and drags immediately he can draw a line from this button to another. I think I have to implement the OnTouchListener interface, but I’m not sure about the condition to recognize this userinteraction. Which MotionEvent or rather which combination of MotionEvents do I need to recognize this input.

I hope you can give me some hints!

grtz warci

  • 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-06-15T17:39:33+00:00Added an answer on June 15, 2026 at 5:39 pm

    Here is my solution:

    @Override
    public boolean onTouch(View v, MotionEvent event) {
        if (event.getAction() == MotionEvent.ACTION_MOVE) {
            Toast.makeText(getActivity(), "onClick", Toast.LENGTH_LONG).show();
            ClipData dragData = ClipData.newPlainText(
                    AbstractFragment.BUTTON_ID_TAG, "" + v.getId());
            DragShadowBuilder shadow = new CanvasDragShadow(v);
            v.startDrag(dragData, shadow, null, 0);
            return true;
        }
        return false;
    }
    

    I added this Method, and it works. Maybe it’s necessary to check the History of MotionEvents to have a better user-experience.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to implement two different dictionaries with a predefined set of valid keys.
I want to implement a scenario where two endpoints can securely communicate with each
I want to implement a class which can be used by two classes of
I have a class that instantiates two classes which implement interfaces. I want one
Basically, I want a class to be able to implement two different versions of
I want to implement a behavior similar to Whatsapp, where when the user can
I am trying to implement this great technique of sharing preferences across two different
I want to implement my app in both landscape and portrait with two different
Java Custom Drag and Drop - no callbacks to TransferHandler. I want to implement
I want to implement two different spinner in Android, the spinner have different data

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.