【发布时间】:2021-02-04 14:58:50
【问题描述】:
我是 kotlin 的新手,在如何将滚动焦点设置在 ArrayList<tags> 的最后一个元素上需要一些帮助,看看我的代码
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/RVTags"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginBottom="12dp"
android:visibility="gone"
app:layout_constraintBottom_toTopOf="@id/startStop"
app:layout_constraintTop_toBottomOf="@id/ui_power_range_inventory_layout"
/>
class FindTagsAdapter internal constructor(
private val ServicesList: ArrayList<Tag>
) :
RecyclerView.Adapter<FindTagViewHolder>() {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): FindTagViewHolder {
return FindTagViewHolder(LayoutInflater.from(parent.context), parent)
}
override fun onBindViewHolder(holder: FindTagViewHolder, position: Int) {
holder.bind(ServicesList[position])
}
override fun getItemCount(): Int {
return ServicesList.size
}
}
【问题讨论】:
-
您想滚动到
RecyclerView中的最后一个元素吗? -
是的,滚动总是停留在最后一个元素上
标签: android kotlin arraylist focus xlm