Legacy Android library for rendering bitmaps. You can load a bitmap from a resource or a file.
- Import the project folder as a library into the Eclipse ADT workspace.
- Add the library to an existing Android application:
- Right-click on your application in Eclipse -> Properties
- Select Android -> Library
- Click on Add ...
- Select the library and click Ok
- Create an instance of
ImageLoader
in your activity. - Use one of the methods
loadImageFromResource()
orloadBitmapFromFile()
to load an image into yourImageView
:
package com.example.bitmaps;
import android.os.Bundle;
import android.widget.ImageView;
import de.s2hmobile.bitmaps.ImageLoader;
public class MainActivity extends Activity {
ImageLoader mImageLoader;
ImageView mImageView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mImageView = (ImageView) findViewById(R.id.image_main);
mImageLoader = new ImageLoader(getResources());
// load drawable into image view, at size 200 x 200
mImageLoader.loadImageFromResource(mImageView, R.drawable.ic_launcher, 200, 200);
}
}