in my app and I'll appreciate some help. I got this recycler view with grid layout manager, the inflated views actually use a selector background and they're supposed to change background whenever any of the views is activated. But the problem is, whenever i activate one view, i find out that some other view down the list changes the background too without interacting with the user, and the whole thing feels weird, I've been up the whole night and this morning trying to debug but I've not been successful. Anyone got any idea what might be going on?
Got an idea. So look recycler uses pool of views right? You have, say 15 views in pool, user interacts with one of them, changing it's state. View remembers this state (new background state in your case). Then you scroll down a bit and recycler picks this view you interacted with and show it down the line with new data. Basically you can't rely on view remembering it's state when you put it in recycler. You need to manage this state on your own
So your problem is that new items are shown in old views. Which is fine. You should manage this thing with which item is selected and which is not on your own. And when you bind data to view in adapter you need to specify if this view is selected or not
Wow!!! Man you just gave me an idea. I'm 100% grateful. The thing is, I'm managing the view state my self, since i have an array list containing values that determines if the view is activated or not. But as usual, logical errors could last hrs, weeks or months to figure out. I knew the view was being reused, but my logic was so messed up. I wasn't doing the right thing. Thanks man, I'm grateful
One more thing sir, do you have a good idea how AUDIO FOCUS LISTENER works? Let's say i request for a transient focus, and then lose the focus to another app requesting for a transient focus. If i regain the focus, which one of these flags would be called? FOCUS_GAIN or FOCUS_GAIN_TRANSIENT? NB: i initially requested for transient focus before losing it to another app
No idea man. Never worked with this thing
Okay man!!! Seems like i'll have to fix this one myself. Thanks again, you really saved me from my own shit✊🏾
Обсуждают сегодня