the codes i used is below:
@Override
public boolean onLongClick(View view) {
// TODO Auto-generated method stub
boolean result = true;
if(DEBUG){
Log.d(TAG, "onLongClick ()");
}
mLongTouch = true;
ClipData.Item item = new ClipData.Item((CharSequence) view.getTag());
ClipData dragData = new ClipData((CharSequence) view.getTag(), mTabDragMimeData, item);
SimeTabDragListener.SimeTabDragShadow myShadow = new SimeTabDragListener.SimeTabDragShadow(view);
view.startDrag(dragData, myShadow, null, 0);
return result;
}
@Override
public boolean onDrag(View view, DragEvent event) {
// TODO Auto-generated method stub
boolean result = true;
int action = event.getAction();
int eventX = (int)event.getX();
int eventY = (int)event.getY();
if(DEBUG){
Log.d(TAG, "onDrag()...event is "+action + ".... X cor is "+event.getX()+"...Y cor is"+event.getY());
}
view.layout(eventX - mDownOffsetsX, eventY - mDownOffsetsY,
eventX + mDownViewWidth - mDownOffsetsX, eventY + mDownViewHeight - mDownOffsetsY);
view.postInvalidate();
return result;
// return super.onDragEvent(event);
}
// drag shadows
public static class SimeTabDragShadow extends View.DragShadowBuilder {
private static Drawable shadow;
public SimeTabDragShadow(View view) {
super(view);
if(DEBUG && view instanceof TextView)
Log.d(TAG, "drag view is text");
shadow = new ColorDrawable(Color.LTGRAY);
}
@Override
public void onProvideShadowMetrics(Point shadowSize,
Point shadowTouchPoint) {
// TODO Auto-generated method stub
super.onProvideShadowMetrics(shadowSize, shadowTouchPoint);
}
@Override
public void onDrawShadow(Canvas canvas) {
// TODO Auto-generated method stub
super.onDrawShadow(canvas);
}
}
and the components(TextView) contained in LinearLayout is static and loaded by XML, problem is other TextView will be disappeared when draging one TextView, and disappear with others when drop it.
is there someone know how it going like this, or how to implement a Drag Gesture within LayoutView, thanks and appreciate guys come here.