Adapter Problems in Searchview

Asked

Viewed 145 times

0

Guys, here’s the deal. In my app, when opening it you have an Activityprincipal, in this Activity I have a Viewpageradapter that shows three Tabs(Let’s call them tab-1, tab-2 and tab-3, each with its Fragment).
Each Tab Loads a list using Recycleview. The data from these lists comes from my webservice.
So far everything is working perfectly.

In the last tab (Tab-3) is where I enable the search using Searchview in my Toolbar (which is working as actionBar).
Activitysearch, responsible for listing the research data, is basically the same Recycleview and Adapter as the one used in Aba-3, and that’s where my problem begins.
I’ll explain.

When I click on the search icon, on my Toolbar (which is acting as actionBar), it opens a field in actionBar itself so I can type in what will be search.
As soon as I type and press Enter (I am using the Genymotion emulator), again a search of my webservice is done and returns a list. This list is passed to the adapter of my Recycleview, which takes care of showing the items on the screen.
What happens is that my Webservice returns a JSON with two objects, but Recicleview only shows the last.
That is, if I do a search that returns 10 objects, my Recicleview only shows 9, always ignoring the first returned. Remember that the same list works correctly when I go to Aba-3.

Does anyone know where to start?

  • How this research is being done in the code?

  • Dude, on my Searhactivity, I’m filling my adapter with data coming from my Webservice. But today I made a very simple adapter that is filled by a List< Pojoteste>, made in the simplest way possible, just so I know if the problem could be coming from the way I fill the list from Webservice, but unfortunately the result is the same.

  • I cannot intend, when I do the search that returns for example 5 items, the adapter of my Recycleview calls right 5 times the event onCreateViewHolder and onBindViewHolder, but when the Recycleview appears on the screen, it always ignores the first item, showing only 4.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.