I want to enable fast scrolling in my sticky header recyclerview
I have below type of recyclerview with sticky header
I'm using https://github.com/Codewaves/Sticky-Header-Grid for sticky header view implementation now i want enable fast scrolling in my recyclerview
I'm using below code
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_clue"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
tools:visibility="gone"
android:clipToPadding="false"
android:paddingTop="8dp"
android:paddingBottom="88dp"
android:scrollbars="vertical"
/>
Adapter code
class ResultsAdapter(private val context: Context) : StickyHeaderGridAdapter(), FastScrollRecyclerView.SectionedAdapter {
private val labels: MutableList<List<String>> = mutableListOf()
private val sectionLabel: MutableList<String> = mutableListOf()
fun setData(sectionList: List<String>, list: List<List<String>>) {
sectionLabel.addAll(sectionList)
labels.addAll(list)
}
override fun getSectionCount(): Int {
return labels.size
}
override fun getSectionItemCount(section: Int): Int {
return labels[section].size
}
override fun onCreateHeaderViewHolder(parent: ViewGroup, headerType: Int): HeaderViewHolder {
val view = LayoutInflater.from(parent.context).inflate(layout.cell_header, parent, false)
return MyHeaderViewHolder(view)
}
override fun onCreateItemViewHolder(parent: ViewGroup, itemType: Int): ItemViewHolder {
val view = LayoutInflater.from(parent.context).inflate(layout.cell_item, parent, false)
return MyItemViewHolder(view)
}
override fun onBindHeaderViewHolder(viewHolder: HeaderViewHolder, section: Int) {
val holder = viewHolder as MyHeaderViewHolder
val label: String = if (TextUtils.isDigitsOnly(sectionLabel[section])) {
if (sectionLabel[section] === "1") {
sectionLabel[section] + " Letter"
} else {
sectionLabel[section] + " Letters"
}
} else {
sectionLabel[section]
}
holder.labelView.text = label
}
override fun onBindItemViewHolder(viewHolder: ItemViewHolder, section: Int, position: Int) {
val holder = viewHolder as MyItemViewHolder
val label = labels[section][position]
holder.labelView.text = label
if (label === context.getString(string.add_words)) {
holder.labelView.setOnClickListener { v: View? -> }
} else if (label === context.getString(string.search_more)) {
holder.labelView.setOnClickListener { v: View? ->
holder.labelView.text = context.getString(string.searching_more)
// MainActivity.getInstance().searchApiCall("", true)
}
}
}
class MyHeaderViewHolder internal constructor(itemView: View) : HeaderViewHolder(itemView) {
var labelView: TextView
init {
labelView = itemView.findViewById(id.label)
}
}
class MyItemViewHolder internal constructor(itemView: View) : ItemViewHolder(itemView) {
var labelView: TextView
init {
labelView = itemView.findViewById(id.label)
}
}
override fun getSectionName(position: Int): String {
return position.toString()
}
}
Till now i have tried many library from github and event tried many stackoverflow answer but still i'm not able to enable fast scrolling in recyclerview
I have tried below answer till now
- How to use fastScrollEnabled in RecyclerView?
- How to add a fast-scroller to the RecyclerView
- Fast Scrolling on RecyclerView
- https://medium.com/android-news/fast-scrolling-with-recyclerview-2b89d4574688
- https://github.com/zhanghai/AndroidFastScroll
can anybody help me to implement fast scrolling in recyclerview
If need more information please do let me know. Thanks in advance. Your efforts will be appreciated