Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You should not cache Drawables -- the Drawable object is very stateful, and intended to be used by one and only one owner.</p> <p>If you want to implement a cache, you should be caching the drawable's constant state.</p> <p>The constant state is retrieve with this:</p> <p><a href="http://developer.android.com/reference/android/graphics/drawable/Drawable.html#getConstantState%28%29" rel="noreferrer">http://developer.android.com/reference/android/graphics/drawable/Drawable.html#getConstantState()</a></p> <p>(Note this method can return null; not all Drawables have constant state.)</p> <p>You can later instantiate new Drawables from a constant state with this:</p> <p><a href="http://developer.android.com/reference/android/graphics/drawable/Drawable.ConstantState.html#newDrawable%28android.content.res.Resources%29" rel="noreferrer">http://developer.android.com/reference/android/graphics/drawable/Drawable.ConstantState.html#newDrawable(android.content.res.Resources)</a></p> <p>Also keep in mind that Resources already maintains a cache of Drawables for you, using this facility, so there is no need for you to implement your own cache for any Drawables you are retrieving from Resources.</p> <p>And if you are making your own Drawables outside of resources, I would strongly recommend making a cache of the underlying data (such as a bitmap downloaded from the network) then trying to mess with the constant state. (And again, definitely don't cache Drawable objects themselves.)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload