如何解决Sqlite Adapterposition 如何从 recylerview 中知道 ID
所以,这是我的主要活动,我知道通过adapterPosition我可以知道我在recyler中的位置我想删除但我需要知道在那个位置有什么ID可以通过查询DELETEBYID删除
override fun onSwiped(viewHolder: ViewHolder,direction: Int) {
Log.d(ContentValues.TAG,viewHolder.adapterPosition.toString())
//notaViewModel.deleteByID(id)
}
这是我在 NotaDao.kt 中的查询
@Query("DELETE FROM Notas_table where id == :id")
suspend fun deleteByID(id: Int)
这是我的适配器,我看到有些人把 id tro 带到这里
override fun onBindViewHolder(holder: NotaViewHolder,position: Int) {
val current = notasss[position]
holder.notaItemView.text = current.id.toString() + " - " + current.titulo + "-" + current.descricao
// val id = current.id;
// holder.notaItemView.setTag(current.id)
// Log.d(TAG,current.id.toString())
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com(将#修改为@)