How to include MIMETYPE_TEXT_PLAIN in creating a ClipData object?

I make the object draggable in the application (the following developer guide for Android ), and it looks like this:

ClipData dragData = new ClipData(v.getTag(), ClipData.MIMETYPE_TEXT_PLAIN, item);

But the IDE gives the following error:

Cannot resolve symbol 'MIMETYPE_TEXT_PLAIN'

So my question is this: how can I get the IDE to recognize MIMETYPE_TEXT_PLAIN?

And yes, I tried (which it seems that this should be the right way) to change ClipData.MIMETYPE_TEXT_PLAINto ClipDescription.MIMETYPE_TEXT_PLAIN, but this seems to make everything worse, as you can see in the following screenshot:

enter image description here

+4
source share
1 answer

You need to use the CharSequence type for first and String for the second parameter.

ClipData dragData = new ClipData((CharSequence) v.getTag(), 
                                 new String[]{ ClipDescription.MIMETYPE_TEXT_PLAIN }, item); 
+13
source

All Articles