Hi Guys, Maybe you all are expert in terms of using RecyclerView in android. This blog is simple example for using filter option with RecyclerView adapter. As for now you will instantiate RecyclerView and set the adapter to RecyclerView as following way. RecyclerView list = (RecyclerView) findViewById(R.id.list); list.setLayoutManager(new LinearLayoutManager(this)); list.setHasFixedSize(true); ArrayList<Number> numbers = new ArrayList<>(); String ONEs[] = {"ZERO", "ONE", "TWO", "THREE", "FOUR", "FIVE", "SIX", "SEVEN", "EIGHT", "NINE", "TEN"}; String TENs[] = {"ZERO", "TEN", "TWENTY", "THIRTY", "FOURTY", "FIFTY", "SIXTY", "SEVENTY", "EIGHTY", "NINETY", "HUNDRED"}; String HUNDREDS[] = {"ZERO", "HUNDRED", "TWO HUND
We can change the RecyclerView from type of ListView to GridView in single line of code.
Video output of sample project
code is:
Video output of sample project:
I hope this post is useful to you. kindly share your feedback as comment here.
Thank You
Video output of sample project
code is:
private void setLayoutManager() { if (mColumnCount <= 1) { mColumnCount = 1; recyclerView.setLayoutManager(new LinearLayoutManager(context)); } else { recyclerView.setLayoutManager(new GridLayoutManager(context, mColumnCount)); } }
Video output of sample project:
Simple RecyclerView example in Android
Simple RecyclerView example with filter option in Android
Simple recyclerview example with checkbox in Android
Source code on GitHub
Thank You
Comments
Post a Comment