I am trying to drag a button on the screen. I can drag, but when I delete, the following error occurs. 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 need to update the current view of the bcoz relocatable object, its drag and drop overload layer, its parent view, but in my current xml button view this is an absolute layout. This error is in onDrop (). I provide his 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;
}
, , , .. refrence , . , : (1) ViewGroup, ; (2) . , Id , : (3) , , . . . , , , ... thanx..