On Fragment file:
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
recycle_home.layoutManager = LinearLayoutManager( this.context , LinearLayout.VERTICAL ,false )
recycle_home.adapter = adapter_home()
}
override fun onActivityCreated(savedInstanceState: Bundle?) { super.onActivityCreated(savedInstanceState)
recycle_home.layoutManager = LinearLayoutManager( this.context)
recycle_home.adapter = adapter_home()
}
Or
override fun onActivityCreated(savedInstanceState: Bundle?) { super.onActivityCreated(savedInstanceState)
recycle_home.layoutManager = LinearLayoutManager( this.context,RecyclerView.VERTICAL,false)
recycle_home.adapter = adapter_home()
}
If you are trying to add layout manager to RecyclerView you can add it inside xml itself
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/emailsRV"
android:layout_width="0dp"
android:layout_height="0dp"
android:adapter="@{adapter}"
android:layoutAnimation="@anim/layout_animation_from_bottom"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_constraintBottom_toTopOf="@id/addNewACB"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:listitem="@layout/item_phone" />
Then if you want to add orientation you can add it in fragment or you can even create a BindingAdapter for the same
Below is the code for fragment/activity
recycle_home.addItemDecoration(DividerItemDecoration(context, LinearLayoutManager.VERTICAL))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.