コレクションでコンテンツを整理
必要に応じて、コンテンツの保存と分類を行います。
DragAndDrop
別のアプリからの、またはアプリ内でのドラッグ&ドロップデータを受け入れ、一貫したドロップ ターゲット アフォーダンスを表示します。
最新の更新 |
安定版リリース |
リリース候補版 |
ベータ版リリース |
アルファ版リリース |
2022 年 5 月 11 日 |
1.0.0 |
- |
- |
- |
依存関係の宣言
DragAndDrop への依存関係を追加するには、Google の Maven リポジトリをプロジェクトに追加する必要があります。詳しくは、Google の Maven リポジトリをご覧ください。
アプリまたはモジュールの build.gradle
ファイルに、必要なアーティファクトの依存関係を追加します。
Groovy
dependencies {
implementation "androidx.draganddrop:draganddrop:1.0.0"
}
Kotlin
dependencies {
implementation("androidx.draganddrop:draganddrop:1.0.0")
}
依存関係について詳しくは、ビルド依存関係の追加をご覧ください。
フィードバック
お寄せいただいたフィードバックは Jetpack 改善の参考にさせていただきます。新しい問題が見つかった場合や、このライブラリを改善するアイデアをお持ちの場合は、お知らせください。新しい問題を報告していただく前に、このライブラリの既存の問題をご確認ください。スターボタンをクリックすると、既存の問題に投票できます。
新しい問題を報告する
詳細については、Issue Tracker のドキュメントをご覧ください。
バージョン 1.0
バージョン 1.0.0
2022 年 5 月 11 日
androidx.draganddrop:draganddrop:1.0.0
がリリースされました。バージョン 1.0.0 に含まれる commit については、こちらをご覧ください。
1.0.0 の主な機能
draganddrop
ライブラリの最初のメンバーである DropHelper
は、ドラッグ&ドロップ機能の実装を簡素化するユーティリティ クラスです。DropHelper
によって、ドロップ ターゲットの指定、ドロップ ターゲットのハイライト表示のカスタマイズ、ドロップされたデータの処理方法の定義が可能です。
DropHelper
は、Jetpack の OnReceiveContentListener
を利用して、ドラッグ&ドロップの ClipData
に対するターゲット固有の処理を提供します。DropHelper
を使用すると、ユーザーがターゲット上にコンテンツをドラッグしたときにハイライト表示されるようにドロップ ターゲットを設定して、ユーザー エクスペリエンスを向上させることができます。また、DropHelper.Options
ネストクラスを使用することで、デフォルトのハイライトの外見をカスタマイズできます。
DropHelper
を使用すると、OnReceiveContentListener
をドロップ ターゲットにアタッチして、ドロップ ターゲットがドラッグ&ドロップ イベントをリッスンするように設定できます。DropHelper
を使用する場合、OnDragListener
や追加の OnReceiveContentListener
をアタッチしてターゲットをドロップすることは避けてください。
DropHelper.Options
を使用すると、複雑なドロップ ターゲットのビュー階層に含まれるすべての EditText
要素を一覧表示できます。その要素がある場合は、このように指定する必要があります。DropHelper
は、ユーザーがターゲット上にデータをドラッグしたときに EditText
要素がドロップ ターゲットからフォーカスを奪取することを防ぎます。ドラッグ&ドロップの ClipData
にテキストと URI データが含まれる場合、DropHelper
は、ClipData
がドロップされたときにテキストデータを処理するドロップ ターゲット内の EditText
要素の一つを選択します。
詳しくは、ドラッグ&ドロップのデベロッパー ガイドをご覧ください。
バージョン 1.0.0-rc01
2022 年 4 月 20 日
androidx.draganddrop:draganddrop:1.0.0-rc01
がリリースされました。バージョン 1.0.0-rc01 に含まれる commit については、こちらをご覧ください。
バージョン 1.0.0-beta01
2022 年 3 月 23 日
androidx.draganddrop:draganddrop:1.0.0-beta01
がリリースされました。バージョン 1.0.0-beta01 に含まれる commit については、こちらをご覧ください。
バージョン 1.0.0-alpha04
2022 年 2 月 23 日
androidx.draganddrop:draganddrop:1.0.0-alpha04
がリリースされました。バージョン 1.0.0-alpha04 に含まれる commit については、こちらをご覧ください。
API の変更
- null ではない localState を持つ DragEvents が、デフォルトでハイライトをトリガーしなくなりました。この動作を変更する構成オプションがあります。(I55792)
バージョン 1.0.0-alpha03
2022 年 1 月 26 日
androidx.draganddrop:draganddrop:1.0.0-alpha03
がリリースされました。バージョン 1.0.0-alpha03 に含まれる commit については、こちらをご覧ください。
新機能
- Android S 以降を搭載したデバイスでは、
DropHelper
から OnReceiveContentListener
のシステム実装へのデリゲートが行われ、ドラッグ&ドロップ以外の入力方法が自動的にサポートされるようになりました。
バージョン 1.0.0-alpha02
2021 年 12 月 15 日
androidx.draganddrop:draganddrop:1.0.0-alpha02
がリリースされました。バージョン 1.0.0-alpha02 に含まれる commit については、こちらをご覧ください。
初回リリースの機能
draganddrop
ライブラリの最初のメンバーである DropHelper
は、ドラッグ&ドロップ機能の実装を簡素化するユーティリティ クラスです。DropHelper
によって、ドロップ ターゲットの指定、ドロップ ターゲットのハイライト表示のカスタマイズ、ドロップされたデータの処理方法の定義が可能です。
DropHelper
は、Jetpack の OnReceiveContentListener
を利用して、ドラッグ&ドロップの ClipData
に対するターゲット固有の処理を提供します。DropHelper
を使用すると、ユーザーがターゲット上にコンテンツをドラッグしたときにハイライト表示されるようにドロップ ターゲットを設定して、ユーザー エクスペリエンスを向上させることができます。また、DropHelper.Options
ネストクラスを使用することで、デフォルトのハイライトの色と角の丸みをカスタマイズできます。
DropHelper.Options
を使用すると、複雑なドロップ ターゲットのビュー階層に含まれるすべての EditText
要素を一覧表示することもできます。DropHelper
は、ユーザーがターゲット上にデータをドラッグしたときに EditText
要素がドロップ ターゲットからフォーカスを奪取することを防ぎます。ドラッグ&ドロップの ClipData
にテキストと URI データが含まれる場合、DropHelper
は、ClipData
がドロップされたときにテキストデータを処理するドロップ ターゲット内の EditText
要素の一つを選択します。
詳しくは、ドラッグ&ドロップのデベロッパー ガイドをご覧ください。
このページのコンテンツやコードサンプルは、コンテンツ ライセンスに記載のライセンスに従います。Java および OpenJDK は Oracle および関連会社の商標または登録商標です。
最終更新日 2025-07-27 UTC。
[[["わかりやすい","easyToUnderstand","thumb-up"],["問題の解決に役立った","solvedMyProblem","thumb-up"],["その他","otherUp","thumb-up"]],[["必要な情報がない","missingTheInformationINeed","thumb-down"],["複雑すぎる / 手順が多すぎる","tooComplicatedTooManySteps","thumb-down"],["最新ではない","outOfDate","thumb-down"],["翻訳に関する問題","translationIssue","thumb-down"],["サンプル / コードに問題がある","samplesCodeIssue","thumb-down"],["その他","otherDown","thumb-down"]],["最終更新日 2025-07-27 UTC。"],[],[],null,["# DragAndDrop\n===========\n\nAPI Reference \n[androidx.draganddrop](/reference/kotlin/androidx/draganddrop/package-summary) \nAccept drag-and-drop data from another app or within an app, and show a consistent drop target affordance. \n\n| Latest Update | Stable Release | Release Candidate | Beta Release | Alpha Release |\n|---------------|-------------------------------------------------------|-------------------|--------------|---------------|\n| May 11, 2022 | [1.0.0](/jetpack/androidx/releases/draganddrop#1.0.0) | - | - | - |\n\nDeclaring dependencies\n----------------------\n\nTo add a dependency on DragAndDrop, you must add the Google Maven repository to your\nproject. Read [Google's Maven repository](/studio/build/dependencies#google-maven)\nfor more information.\n\nAdd the dependencies for the artifacts you need in the `build.gradle` file for\nyour app or module: \n\n### Groovy\n\n```groovy\ndependencies {\n implementation \"androidx.draganddrop:draganddrop:1.0.0\"\n}\n```\n\n### Kotlin\n\n```kotlin\ndependencies {\n implementation(\"androidx.draganddrop:draganddrop:1.0.0\")\n}\n```\n\nFor more information about dependencies, see [Add build dependencies](/studio/build/dependencies).\n\nFeedback\n--------\n\nYour feedback helps make Jetpack better. Let us know if you discover new issues or have\nideas for improving this library. Please take a look at the\n[existing issues](https://issuetracker.google.com/issues?q=componentid:1139019%20status:open)\nin this library before you create a new one. You can add your vote to an existing issue by\nclicking the star button.\n\n[Create a new issue](https://issuetracker.google.com/issues/new?component=1139019&template=1644483)\n\nSee the [Issue Tracker documentation](https://developers.google.com/issue-tracker)\nfor more information.\n\nVersion 1.0\n-----------\n\n### Version 1.0.0\n\nMay 11, 2022\n\n`androidx.draganddrop:draganddrop:1.0.0` is released. [Version 1.0.0 contains these commits.](https://android.googlesource.com/platform/frameworks/support/+log/792d15289c94ffb5121f8e0ea664cc758926ff49..50f2d1d62c4cb89366df3bf9f811754b8cdda677/draganddrop/draganddrop)\n\n**Major features of 1.0.0**\n\n`DropHelper`, the first member of the `draganddrop` library, is a utility class that simplifies implementation of drag and drop capabilities. Use `DropHelper` to specify drop targets, customize drop target highlighting, and define how dropped data is handled.\n\n- `DropHelper` leverages Jetpack's [`OnReceiveContentListener`](/reference/androidx/core/view/OnReceiveContentListener) to provide target-specific processing of drag and drop [`ClipData`](/reference/android/content/ClipData). `DropHelper` enhances the user experience by configuring drop targets to display a highlight as users drag content over the targets. The `DropHelper.Options` nested class enables you to customize the appearance of the default highlight.\n- `DropHelper` attaches an [`OnReceiveContentListener`](/reference/androidx/core/view/OnReceiveContentListener) to drop targets and configures drop targets to listen for drag and drop events. Do not attach an [`OnDragListener`](/jetpack/androidx/releases/m/reference/android/view/View.OnDragListener) or additional `OnReceiveContentListener` to drop targets when using `DropHelper`.\n- `DropHelper.Options` gives you the ability to list all [`EditText`](/reference/android/widget/EditText) elements contained in the view hierarchy of complex drop targets. If any are present, they must be specified in this way. `DropHelper` prevents the `EditText` elements from stealing focus from the drop target when users drag data over the target. If the drag and drop `ClipData` includes text and URI data, `DropHelper` selects one of the `EditText` elements in the drop target to handle the text data when the `ClipData` is dropped.\n\nFor more information, see the [Drag and drop](/guide/topics/ui/drag-drop#drophelper) developer's guide.\n\n### Version 1.0.0-rc01\n\nApril 20, 2022\n\n`androidx.draganddrop:draganddrop:1.0.0-rc01` is released. [Version 1.0.0-rc01 contains these commits.](https://android.googlesource.com/platform/frameworks/support/+log/5ef5671233460b844828e14a816255dbf7904868..792d15289c94ffb5121f8e0ea664cc758926ff49/draganddrop/draganddrop)\n\n- No changes since the last beta release.\n\n### Version 1.0.0-beta01\n\nMarch 23, 2022\n\n`androidx.draganddrop:draganddrop:1.0.0-beta01` is released. [Version 1.0.0-beta01 contains these commits.](https://android.googlesource.com/platform/frameworks/support/+log/9b2b3d8efd5f00bd4af903bbaa926f6a712d0bd8..5ef5671233460b844828e14a816255dbf7904868/draganddrop/draganddrop)\n\n- No changes since last alpha release.\n\n### Version 1.0.0-alpha04\n\nFebruary 23, 2022\n\n`androidx.draganddrop:draganddrop:1.0.0-alpha04` is released. [Version 1.0.0-alpha04 contains these commits.](https://android.googlesource.com/platform/frameworks/support/+log/9dceceb54300ed028a7e8fc7a3454f270337ffde..9b2b3d8efd5f00bd4af903bbaa926f6a712d0bd8/draganddrop/draganddrop)\n\n**API Changes**\n\n- DragEvents with a non-null localState will not trigger highlighting by default. There is a configuration option to change this behavior. ([I55792](https://android-review.googlesource.com/#/q/I55792b436b346ed9e5fa092c88b4e878087d1395))\n\n### Version 1.0.0-alpha03\n\nJanuary 26, 2022\n\n`androidx.draganddrop:draganddrop:1.0.0-alpha03` is released. [Version 1.0.0-alpha03 contains these commits.](https://android.googlesource.com/platform/frameworks/support/+log/301586664b5aad60548f21866cad502d524dbf9f..9dceceb54300ed028a7e8fc7a3454f270337ffde/draganddrop/draganddrop)\n\n**New Features**\n\n- On devices running Android S or later, `DropHelper` now delegates to the system implementation of `OnReceiveContentListener`, automatically providing support for input methods other than drag and drop.\n\n### Version 1.0.0-alpha02\n\nDecember 15, 2021\n\n`androidx.draganddrop:draganddrop:1.0.0-alpha02` is released. [Version 1.0.0-alpha02 contains these commits.](https://android.googlesource.com/platform/frameworks/support/+log/301586664b5aad60548f21866cad502d524dbf9f/draganddrop/draganddrop)\n\n**Features in initial release**\n\n`DropHelper`, the first member of the `draganddrop` library, is a utility class that simplifies implementation of drag and drop capabilities. Use `DropHelper` to specify drop targets, customize drop target highlighting, and define how dropped data is handled.\n\n`DropHelper` leverages Jetpack's [`OnReceiveContentListener`](/reference/androidx/core/view/OnReceiveContentListener) to provide target-specific processing of drag and drop [`ClipData`](https://developer.android.com/reference/android/content/ClipData). `DropHelper` enhances the user experience by configuring drop targets to display a highlight as users drag content over the targets. The `DropHelper.Options` nested class enables you to customize the color and corner radius of the default highlight.\n\n`DropHelper.Options` also gives you the ability to list all [`EditText`](/reference/android/widget/EditText) elements contained in the view hierarchy of complex drop targets. `DropHelper` prevents the `EditText` elements from stealing focus from the drop target when users drag data over the target. If the drag and drop `ClipData` includes text and URI data, `DropHelper` selects one of the `EditText` elements in the drop target to handle the text data when the `ClipData` is dropped.\n\nFor more information, see the [Drag and drop](/guide/topics/ui/drag-drop) developer's guide."]]