【发布时间】:2021-08-22 02:46:44
【问题描述】:
我想实现一个拖拽排序列表,功能类似于drag-sort-recyclerview/gridview,但是使用jetpack compose。
【问题讨论】:
-
它似乎有什么问题?到目前为止,您尝试过什么?
-
这能回答你的问题吗? Reorder LazyColumn items with drag & drop
我想实现一个拖拽排序列表,功能类似于drag-sort-recyclerview/gridview,但是使用jetpack compose。
【问题讨论】:
使用这个库是有帮助的 这是我的用法示例
implementation("org.burnoutcrew.composereorderable:reorderable:0.6.1")
val state = rememberReorderState()
val list=notes.toMutableList()
LazyColumn(
state = state.listState,
modifier = Modifier.reorderable(state, { a, b -> list.move(a, b) })
) {
items(list, { it.id }) { noteIndex ->
Note(
Modifier
.draggedItem(state.offsetByKey(noteIndex.id))
.detectReorderAfterLongPress(state),
note = noteIndex,
onNoteClick = onNoteClick,
onNoteCheckedChange = onNoteCheckedChange
)
}
}
【讨论】: