My code is showing this warning message:
Typed Array should be recycled after use with #recycle() for obtainedTypedArray
Code:
public View getView(int i, View view, ViewGroup viewgroup)
{
ImageView imageview;
if (view == null)
{
imageview = new ImageView(b);
imageview.setLayoutParams(new android.widget.AbsListView.LayoutParams(110, 110));
imageview.setPadding(1, 1, 1, 1);
imageview.setAdjustViewBounds(false);
imageview.setScaleType(android.widget.ImageView.ScaleType.CENTER_CROP);
} else
{
imageview = (ImageView)view;
}
imageview.setImageResource(a.getResources().obtainTypedArray(0x7f050000).getResourceId(i, -1)); //*warning*Typed Array should be recycled after use with #recycle()
return imageview;
}
Array in java is a group of like-typed variables referred to by a common name. Arrays in Java work differently than they do in C/C++.
recycle basically means..free/clearing all the data associated with corresponding resource. In Android we can find recycle for Bitmap and TypedArray. If you check both source files then you can find a boolean variable "mRecycled" which is "false"(default value). It is assigned to "true" when recycle is called.
toTypedArray(): Array<T> Returns a typed array containing all of the elements of this collection. Allocates an array of runtime type T having its size equal to the size of this collection and populates the array with the elements of this collection.
The JavaScript TypedArray object illustrates an array like view of an underlying binary data buffer. There are many number of different global properties, whose values are TypedArray constructors for specific element types, listed below.
You should hold onto the TypedArray
you get back from obtainTypedArray()
and call recycle()
on it after using it.
Also, hard-coding a hex value like 0x7f050000
is unlikely to be the right answer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With