【问题标题】:How do I use Jepack compose to implement a drag sorted list?如何使用 Jetpack compose 实现拖动排序列表?
【发布时间】:2021-08-22 02:46:44
【问题描述】:

我想实现一个拖拽排序列表,功能类似于drag-sort-recyclerview/gridview,但是使用jetpack compose。

【问题讨论】:

标签: android-jetpack-compose


【解决方案1】:

使用这个库是有帮助的 这是我的用法示例

  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
        )
     }
}

【讨论】:

  • 图书馆是什么?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2022-08-17
  • 1970-01-01
  • 1970-01-01
  • 2022-12-22
  • 2023-01-29
  • 2022-10-25
  • 2022-10-26
相关资源
最近更新 更多