문제

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;
}
도움이 되었습니까?

해결책 2

use a recycle(); at the end of your obtainTypedArray() statement. do not use hex values, may lead to complications in your code in future.

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top