Closed Rainer-Lang closed 7 years ago
No, it is not required. You can add the FastScroller
view to your layout with a RecyclerView
and set it up manually. Creating a class that extends RecyclerView
made the implementation simpler.
Oh great! May I ask for an example?
Using the included example:
private FastScroller fastScroller;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ExampleAdapter adapter = new ExampleAdapter();
RecyclerView recyclerView = findViewById(R.id.recycler_view);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
recyclerView.setAdapter(adapter);
fastScroller = findViewById(R.id.fast_scroller);
fastScroller.setSectionIndexer(adapter);
fastScroller.attachRecyclerView(recyclerView);
}
@Override
protected void onDestroy() {
fastScroller.detachRecyclerView();
super.onDestroy();
}
private static class ExampleAdapter extends RecyclerView.Adapter<ExampleAdapter.ViewHolder> implements FastScroller.SectionIndexer {
...
@Override
public String getSectionText(int position) {
return String.valueOf(mItemList.get(position).charAt(0));
}
}
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<com.l4digital.fastscroll.FastScroller
android:id="@+id/fast_scroller"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="end"
app:bubbleColor="@color/fastscroll_bubble"
app:bubbleTextColor="@color/fastscroll_text"
app:handleColor="@color/fastscroll_handle" />
@randr0id Thanks a lot. I'll try it in the next days.
@randr0id I guess, you need to add this way into readme
Have a look here: https://github.com/turing-tech/MaterialScrollBar