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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:43:09+00:00 2026-05-27T05:43:09+00:00

I am trying to drag and drop a button on the screen.i can drag

  • 0

I am trying to drag and drop a button on the screen.i can drag but when i drop the following error takes place.
Logcat:

12-05 15:03:00.905: E/AndroidRuntime(1009): java.lang.IllegalArgumentException: Given view not a child of com.avigma.learning.DragLayer@44f5eda0
12-05 15:03:00.905: E/AndroidRuntime(1009):     at android.view.ViewGroup.updateViewLayout(ViewGroup.java:1876)
12-05 15:03:00.905: E/AndroidRuntime(1009):     at com.avigma.learning.DragLayer.onDrop(DragLayer.java:131)
12-05 15:03:00.905: E/AndroidRuntime(1009):     at com.avigma.learning.DragController.drop(DragController.java:447)
12-05 15:03:00.905: E/AndroidRuntime(1009):     at com.avigma.learning.DragController.onTouchEvent(DragController.java:424)
12-05 15:03:00.905: E/AndroidRuntime(1009):     at com.avigma.learning.DragLayer.onTouchEvent(DragLayer.java:69)

xml:-

<?xml version="1.0" encoding="utf-8"?>
<com.avigma.learning.DragLayer
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:launcher="http://schemas.android.com/apk/res/com.android.launcher"

    android:id="@+id/drag_layer"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >


  <ImageView
        android:id="@+id/imageView1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
       android:src="@drawable/b" />

  <ScrollView
      android:id="@+id/scrollView1"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:layout_x="-4dp"
      android:layout_y="2dp" >


      <AbsoluteLayout
          android:id="@+id/ll"
          android:layout_width="match_parent"
          android:layout_height="match_parent" >

   //This button i am dragging and dropping
<Button
    android:id="@+id/button2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_x="84dp"
    android:layout_y="90dp"
    android:background="@null"
    android:text="B"
    android:textColor="#000000"
    android:textSize="35dp"
    android:textStyle="bold"
    android:typeface="serif" />

</AbsoluteLayout>


  </ScrollView>

</AbsoluteLayout>
</com.avigma.learning.DragLayer>

I think i have to update the current view of movable object bcoz its refrencing drag layer its parent view but in my xml button current view is absolute layout.this error is in onDrop().I am providing its code:-

 private boolean drop(float x, float y) {

    final int[] coordinates = mCoordinatesTemp;
    DropTarget dropTarget = findDropTarget((int) x, (int) y, coordinates);

    if (dropTarget != null) {
        dropTarget.onDragExit(mDragSource, coordinates[0], coordinates[1],
                (int) mTouchOffsetX, (int) mTouchOffsetY, mDragView, mDragInfo);
        if (dropTarget.acceptDrop(mDragSource, coordinates[0], coordinates[1],
                (int) mTouchOffsetX, (int) mTouchOffsetY, mDragView, mDragInfo)) {

            dropTarget.onDrop(mDragSource, coordinates[0], coordinates[1],
                    (int) mTouchOffsetX, (int) mTouchOffsetY, mDragView, mDragInfo);
            mDragSource.onDropCompleted((View) dropTarget, true);
            return true;
        } else {
            mDragSource.onDropCompleted((View) dropTarget, false);
            return true;
        }
    }
    return false;
}

please help that what should i do to overcome this issue..or how to handle that button should not refrence drag layer its current parent view but absolute layout..I know whats the problem that either(1) move everything under one ViewGroup so all the movable views have the same parent view; (2) arrange to change the parent view of the view being moved when that view is dropped. But today I think I’d try what I suggested above: (3) in the view that is accepting the drop, make a copy of the view being dragged. Attach the copy as a child of that view. Go back to the original view and remove it from its parent.But how to code that to fix it please assist me…thanx..

  • 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-27T05:43:10+00:00Added an answer on May 27, 2026 at 5:43 am

    Simply use this method:

    public interface DropListener {
    
    /**
     * Called when an item is to be dropped.
     * @param from - index item started at.
     * @param to - index to place item at.
     */
    void onDrop(int from, int to);
    }
    

    You can see here. And, let you can know more detail.

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

Sidebar

Related Questions

I'm experimenting with HTML5's Drag and Drop. I'm trying to drag an html button.
i'm trying to drag and drop a button the problem is that when i
I am trying to perform a simple drag-n-drop operation starting from one button in
I'm trying to implement drag/drop/sort between 2 list elements: <ul id=first> <li>item 1</li> <li>item
I'm trying to implement drag and drop behaviour between a bunch of ListViews. I've
I'm trying to implement drag and drop functionality in a Surface Application that is
We're trying to implement drag and drop in Silverlight (3). We want users to
I am trying to implement drag and drop for a treeview control that binds
I am trying to handle a drag & drop interaction, which involves mouse down,
I'm trying to drag a UIImageView according to an anchorPoint but the whole image

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.