how to make Stagered RecyclerView? so that the columns stand randomly, i'm Beginner and so much tutorial stageredrecyclerview by java, about Kotlin tutorial how to make randomly stageredRecyclerView unfortunatly I haven't found , can someone bring simple please. thank advance
this is my code (column and Stagered Manager I already wrote in xml)
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:background="#F4F4F4"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/RecyclerView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layoutManager="androidx.recyclerview.widget.StaggeredGridLayoutManager"
app:spanCount="2"
app:layout_constraintTop_toTopOf="parent"
tools:listitem="@layout/item_recycler"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
class AgroMarktFragment: Fragment(), IntFaceClickRecycler {
var binding : AgromarktLayoutBinding? = null
private val vm by viewModel<AgroMarkViewModel>()
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
binding = AgromarktLayoutBinding.inflate(layoutInflater)
return binding?.root
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
hereWeGo()
}
private fun hereWeGo() {
val adapter = AgroAdapter(this)
binding?.RecyclerView?.adapter = adapter
vm.data.observe(viewLifecycleOwner, Observer {
adapter.update(it)
})
}
override fun gotoTheDetails(data: Dataclass) {
val dest = HomeFragmentDirections.actionHomeFragmentToDetailsFragment(data)
findNavController().navigate(dest)
}
}