I want to do a RESET button. I already successfully do for Spinner and Seekbar but failed to do for RecyclerView which is my filtering result. There is no error, but as you can see in my output interface, ONLY the recyclerView did not empty...
My coding:-
resetButton.setOnClickListener(new View.OnClickListener() {
final MediaPlayer mediaPlayer = MediaPlayer.create(FilterTuitionCentre.this, R.raw.soundeffect1);
@Override
public void onClick(View v) {
mediaPlayer.start();
spLocation.setSelection(0);
seekbarPrice.setProgress(0);
spAcademicLevel.setSelection(0);
spSubject.setSelection(0);
recyclerView.invalidate();
}
});
My interface output:-

My adapter coding:-
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getApplicationContext());
recyclerView.setLayoutManager(linearLayoutManager);
recyclerView.setAdapter(mAdapter);
I assume that you have following initialization for your recyclerView :
YourAdapter adapter = new YourAdapter(items);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
recyclerView.setAdapter(adapter);
To clear items(Empty) RecyclerView you need to :
items.clear();
adapter.notifyDataSetChanged();
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