how to cache images?
Here is an example step-by-step on how to cache images, in memory and disk:
http://androidexample.com/Download_Images_From_Web_And_Lazy_Load_In_ListView_-_Android_Example/index.php?view=article_discription&aid=112&aaid=134
But you can also use libs that already work pretty well like :
http://square.github.io/picasso/
The first link also contains explanation on how you should treat bitmaps to avoid outOfMemory.
Coil image caching
Try disabling the cache headers support.
val imageLoader = ImageLoader.Builder(context)
.respectCacheHeaders(false)
.build()
Coil.setImageLoader(imageLoader)
Android Image caching
You can simple use Picasso library to handle this, it wil do everything for you
Picasso.with(context).load(R.drawable.drawableName).into(imageView);
In your adapter :
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if (convertView == null) {
holder = new ViewHolder();
convertView = inflater.inflate(R.layout.list_item, parent, false);
holder.imageView = (ImageView) convertView.findViewById(R.id.imageView);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
Picasso.with(context).load(R.drawable.drawableName).into(imageView);
return convertView;
}
class ViewHolder {
ImageView imageView;
}
Link: https://github.com/square/picasso
Or if you still not like to use Picasso, let's comment, i'll share you some class to modify image, save to cache and load up, but it so long...
Related Topics
Autocompletetextview Backed by Cursorloader
Play Audio File from the Assets Directory
Enabling Proguard in Eclipse for Android
Read All Contacts' Phone Numbers in Android
How to Put a Border Around an Android Textview
Webview Load HTML from Assets Directory
How to Ignore Accent in SQLite Query (Android)
Force Application to Restart on First Activity
Data Sharing Between Two Applications
How to Maintain Fragment State When Added to the Back Stack
Importing Google-Play-Service Library Showing a Red X Next to This Reference Android
Capture Screen Shot of Googlemap Android API V2
How to Adjust Layout When Soft Keyboard Appears
Android: Getting a File Uri from a Content Uri
What Is an Android Pendingintent
How to Keep the Screen on in My App