具体setHasTransientState(boolean)
。 如何以及为什么使用它?我正在寻找“现实生活”场景。
文档定义:
Set whether this view is currently tracking transient state that the framework should attempt to preserve when possible. This flag is reference counted, so every call to setHasTransientState(true) should be paired with a later call to setHasTransientState(false).
A view with transient state cannot be trivially rebound from an external data source, such as an adapter binding item views in a list. This may be because the view is performing an animation, tracking user selection of content, or similar.
最佳答案
如果view是listview项,setHasTransientState可以防止其回收。如果是在动画中,则很有用。 transient 只是一种特殊的状态,我认为这意味着不要碰我(作为回收),我很快就会变得不再 transient 。
关于android - View.hasTransientState() 的目的是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38048681/