saintjab
saintjab

Reputation: 1642

Update height of RecyclerView

I have a layout with ViewFlipper -> NestScrollview -> LinearLayout (parent to two RecyclerViews). Both RV have height set to wrap_content and setNestedScrollingEnable(false). Now the issue is whenever one of the RV has its adapter filtered, its still maintains it old view size even though the number of items has reduced. How can I make the RV size to adapter to new changes in the item size? I realised this started happening when I nested the two RVs in the NestedScrollView. Anyway to update the child view sizes when the content of RVs are updated. Calling notifyDataSetChanged() is't updating the view size

Upvotes: 0

Views: 727

Answers (1)

Joaquín
Joaquín

Reputation: 1126

It should Work if you put notifyDataSetChanged in your adapter every time your list is filtered. Here's an example of one of my projects where I filter a list based on a searchview Query and every time the list gets reasigned I call notifyDataSetChanged() in the adapter

 @Override
            protected void publishResults(CharSequence charSequence, FilterResults filterResults) {
                if (!listFiltered.isEmpty()) {
                    listItems = (ArrayList<ListaConsultaFamilia>) filterResults.values;
                    notifyDataSetChanged();
                }
            }

Upvotes: 1

Related Questions