【发布时间】:2016-03-15 09:03:48
【问题描述】:
为了将图像加载到列表视图(在我的情况下为 25 kb“个人资料”图片),我昨天绑定了 picasso,以便更快地加载图像并缓存到磁盘。但从那时起,即使我没有打开加载图像的活动,我也会经常出现内存不足的错误。 难道是缓存没有被清除,所以我的应用程序不能再处理任何服务器请求了吗?有人也遇到过这个问题吗?还是我基本上做错了什么?
通常我的应用程序首先加载谷歌地图,标记放置在 JSON 请求给出的特定位置。如果我滑动到另一个位置来加载这些标记,则在尝试从服务器加载 JSON 时会发生内存不足错误。以前从未发生过,只是因为我在我的应用程序中包含了毕加索库。
这是我的列表视图列表项:
<?xml version="1.0" encoding="utf-8"?>
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent">
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:padding="8dp"
android:id="@+id/friends_image"
/>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?android:attr/listPreferredItemHeight"
android:layout_toRightOf="@+id/friends_image"
android:gravity="center_vertical"
android:id="@+id/list_item_friends_textview" />
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/text_view_id"
/>
【问题讨论】:
-
你的图片有这个属性吗? :
android:adjustViewBounds="true"也试过.fit().centerCrop() -
将它添加到你所有的图像视图中并再次测试它,如果它抛出内存不足,请告诉我
-
还是同样的错误。还有其他建议吗?
标签: android json android-asynctask out-of-memory picasso