Похожие чаты

Hello guys, got a couple of weird stuffs going on

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?

8 ответов

14 просмотров

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

Nnaoma-M Автор вопроса
Roman Chumachenko
So your problem is that new items are shown in old...

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

Nnaoma-M Автор вопроса
Roman Chumachenko
Glad it helped 😁

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

Nnaoma-M Автор вопроса
Roman Chumachenko
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✊🏾

Похожие вопросы

Обсуждают сегодня

Господа, а что сейчас вообще с рынком труда на делфи происходит? Какова ситуация?
Rꙮman Yankꙮvsky
29
А вообще, что может смущать в самой Julia - бы сказал, что нет единого стандартного подхода по многим моментам, поэтому многое выглядит как "хаки" и произвол. Короче говоря, с...
Viktor G.
2
@Benzenoid can you tell me the easiest, and safest way to bu.y HEX now?
Živa Žena
20
This is a question from my wife who make a fortune with memes 😂😂 About the Migration and Tokens: 1. How will the old tokens be migrated to the new $LGCYX network? What is th...
🍿 °anton°
2
30500 за редактор? )
Владимир
47
а через ESC-код ?
Alexey Kulakov
29
What is the Dex situation? Agora team started with the Pnetwork for their dex which helped them both with integration. It’s completed but as you can see from the Pnetwork ann...
Ben
1
Гайс, вопрос для разносторонее развитых: читаю стрим с юарта, нада выделять с него фреймы с определенной структурой, если ли чо готовое, или долбаться с ринг буффером? нада у...
Vitaly
9
Anyone knows where there are some instructions or discort about failed bridge transactions ?
Jochem
21
@lozuk how do I get my phex copies of my ehex from a atomic wallet, to move to my rabby?
Justfrontin 👀
11
Карта сайта