I have a recyclerview which works as expected. I have a button in the layout that fills the list. The button is supposed to make a async call, and on result, I change the button
Chet Haase from Google discusses your exact issue in this DevBytes video.
In short, the framework need to be notified that one of the Views is in "transient" state. Once notified, the framework will not recycle this View until its "transient" flag cleared.
In your case, before you execute the async action, call setHasTransientState(true)
on the child View that should change when the async action completes. This View will not be recycled until you explicitly call setHasTransientState(false)
on it.
Offtopic:
It looks like you might be manipulating UI elements from background threads. Don't do that! If you can have a reference to Activity
then use its runOnUiThread(Runnable action)
API instead. If getting a reference to Activity
is difficult, you can obtain UI thread's Handler
and use its post(Runnable action)
API.