我使用毕加索来加载有大约900张图片的资产文件中的图片。但是当我滑动ListView时,logcat会出现内存不足。
我的自定义listrow places_layout.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/iv_test"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"/>
</RelativeLayout>
我的自定义适配器getView代码
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder=null;
if(convertView==null){
holder=new ViewHolder();
convertView= LayoutInflater.from(mContext).inflate(R.layout.list_item,null);
holder.mImageView=(ImageView)convertView.findViewById(R.id.iv_test);
convertView.setTag(holder);
}else {
holder=(ViewHolder)convertView.getTag();
}
Picasso.with(mContext).load("file:///android_asset/picture/" + mPictureNames.get(position)).resize(200,200).into(holder.mImageView);
// holder.mImageView.setImageBitmap(getPicture(position));
return convertView;
}