How to load image in Viewholder of MovieAdapter?

后端 未结 2 1247
北海茫月
北海茫月 2020-12-21 17:38

Main Code

protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.mo         


        
2条回答
  •  忘掉有多难
    2020-12-21 18:25

    I am using this library and loading images by

    first creating the Display options object by

        DisplayImageOptions builder = new DisplayImageOptions.Builder()
                                    .cacheOnDisk(true)
                                    .showImageOnLoading(R.drawable.empty_photo)        
                                    .showImageForEmptyUri(R.drawable.empty_photo)
                                    .build();
    

    Then initialze the image loader by

      ImageLoader imageLoader = ImageLoader.getInstance();
    

    and load images by

     imageLoader.displayImage(url, imageView, builder);
    

    Hope this helps.. also add this to you gradle

      compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
    

    Refer this first

    EDIT: Add this to onCreate() of activity

        ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(this)
            ...
            .build();
        ImageLoader.getInstance().init(config);
    

    or this

       ImageLoader.getInstance().init(ImageLoaderConfiguration.createDefault(Activity.this‌​));
    

提交回复
热议问题