Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/220.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android DragShadowBuilder视图刷新_Android_Drag And Drop_Textview - Fatal编程技术网

Android DragShadowBuilder视图刷新

Android DragShadowBuilder视图刷新,android,drag-and-drop,textview,Android,Drag And Drop,Textview,我正在我的应用程序中实现拖放功能。 我正在移动TextView对象,并使用DragShadowBuilder为该TextView构建阴影。 问题是,有没有办法在拖动项目时更改textView文本?我是说在 DrageEvent.ACTION\u DRAG\u输入或DrageEvent.ACTION\u DRAG\u位置案例 private static class MyDragShadowBuilder extends View.DragShadowBuilder { // The drag

我正在我的应用程序中实现拖放功能。 我正在移动TextView对象,并使用DragShadowBuilder为该TextView构建阴影。 问题是,有没有办法在拖动项目时更改textView文本?我是说在 DrageEvent.ACTION\u DRAG\u输入或DrageEvent.ACTION\u DRAG\u位置案例

private static class MyDragShadowBuilder extends View.DragShadowBuilder {

// The drag shadow image, defined as a drawable thing
private static Drawable shadow;

    // Defines the constructor for myDragShadowBuilder
    public MyDragShadowBuilder(View v) {

        // Stores the View parameter passed to myDragShadowBuilder.
        super(v);

        // Creates a draggable image that will fill the Canvas provided by the system.
        shadow = new ColorDrawable(Color.LTGRAY);
    }

    // Defines a callback that sends the drag shadow dimensions and touch point back to the
    // system.
    @Override
    public void onProvideShadowMetrics (Point size, Point touch)
        // Defines local variables
        private int width, height;

        // Sets the width of the shadow to half the width of the original View
        width = getView().getWidth() / 2;

        // Sets the height of the shadow to half the height of the original View
        height = getView().getHeight() / 2;

        // The drag shadow is a ColorDrawable. This sets its dimensions to be the same as the
        // Canvas that the system will provide. As a result, the drag shadow will fill the
        // Canvas.
        shadow.setBounds(0, 0, width, height);

        // Sets the size parameter's width and height values. These get back to the system
        // through the size parameter.
        size.set(width, height);

        // Sets the touch point's position to be in the middle of the drag shadow
        touch.set(width / 2, height / 2);
    }

    // Defines a callback that draws the drag shadow in a Canvas that the system constructs
    // from the dimensions passed in onProvideShadowMetrics().
    @Override
    public void onDrawShadow(Canvas canvas) {

        // Draws the ColorDrawable in the Canvas passed in from the system.
        shadow.draw(canvas);
    }
}