Well, I want to change the span count of recycler view Grid layout manager's dynamically on click of a button.
GridLayoutManager manager;
@Override
public void onClick(View v) {
if(manager.getSpanCount() > 16)
{
manager.setSpanCount(1);
}
manager.setSpanCount( manager.getSpanCount()+1);
mRecyclerView.setLayoutManager(manager);
}
but when i try to change it on OnCreate in activity
it changes the gridSpanCount in the recyclerView.
Please tell me how to fix it. and it is also not working in onTouchListener on the view.
Just call adapter's notifyDataSetChanged()
after setting new span count value.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With