PlainText (); Can it go empty?

2

Hi, I've been seeing examples of an Drag&Drop from android studio but in an example I saw, this appears:

View.OnLongClickListener longClickListener = new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            ClipData dragData = new ClipData.newPlainText("","");
            View.DragShadowBuilder myShadowBuilder = new View.DragShadowBuilder(v);
            v.startDrag(dragData, myShadowBuilder, v, 0);
            return true;
        }
    };

My doubt is that when I pass it to Android, it marks me an error when writing the plainText .

    
asked by Sandra Green 20.04.2017 в 03:06
source

1 answer

0

The parameters of ClipData.newPlainText() are the title and the text you want to be saved in the clipboard, example:

new ClipData.newPlainText("PlainText puede ir vacio?","Hola he estado viendo ejemplos de un drag & drop de android studio pero en un ejemplo que vi aparece esto:");

As for not recognizing the method, you have to add the package of the class:

android.content.ClipData dragData = android.content.ClipData.newPlainText("","");
    
answered by 20.04.2017 в 16:48