Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
DnD in Compose
Search
punchdrunker
April 04, 2025
340
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
DnD in Compose
punchdrunker
April 04, 2025
More Decks by punchdrunker
See All by punchdrunker
Kotlin2.0以降の新機能
punchdrunker
0
58
what's new in Material Design で気になったトピック
punchdrunker
1
650
7カ国語に対応したサービスでの翻訳管理システムの改善事例
punchdrunker
1
1.5k
Java Bytecode Vertical Tasting
punchdrunker
2
1.6k
getting started with dark theme
punchdrunker
2
1.1k
Practical Activity Transition in Android
punchdrunker
0
1.3k
今時のProgress indicator / Replacing ProgressDialog with ProgressBar
punchdrunker
0
740
レビュー評価4.7の秘密 / The Secret To A Better Reputation
punchdrunker
2
2.1k
Dynamic Feature Modules 入門
punchdrunker
2
2.8k
Featured
See All Featured
Building Adaptive Systems
keathley
44
3.2k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.5k
brightonSEO & MeasureFest 2025 - Christian Goodrich - Winning strategies for Black Friday CRO & PPC
cargoodrich
3
760
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
123
22k
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.3k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
162
16k
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
3
380
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
310
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
680
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.5k
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
330
Embracing the Ebb and Flow
colly
88
5.1k
Transcript
DnD in Compose @punchdrunker 2025/4/4
自己紹介 - 2010〜 Android / iOS Dev - Director of
DroidKaigi Association - MNG - Tamagotchi Connect
ComposeでもDnD(ドラッグアンドドロップ)できる? - Jetpack Compose 1.6からDnDサポート追加 - 具体的には dragAndDropSource と dragAndDropTarget
を使う - Viewベースと同じく ClipData でデータを渡せる
最小限の実装の流れ 構成 - Modifier.dragAndDropSource → ドラッグしたいもの - ClipDataで中身を渡す - Modifier.dragAndDropTarget
→ ドロップ先 - DragAndDropEventでイベント受け取り 📦 データの受け渡しは ClipData.newPlainText("label", "value") みたいな感じ
example: dragAndDropSource
example: dragAndDropTarget 1/2
example: dragAndDropTarget 2/2 onDropだけ 実装必須
example: DragAndDropEvent - DragAndDropEvent - mimeType - DragEvent - Offset
- ClipData - …(たくさん)
まとめ まとめ: - ComposeでもDnDができるようになった - Modifierベースで導入も簡単 - ClipDataとDragAndDropEventの理解がポイント - 外部アプリからのDnD対応もできそうなのでやってみたい
- ファイルDnDなども試す予定!
Resources - actual code: https://github.com/punchdrunker/compose-drag-and-drop/blob/main/app/src/ main/java/com/example/myapplication/MainActivity.kt - overview: https://developer.android.com/reference/kotlin/androidx/compose/foundation/d raganddrop/package-summary
-