खोज…


टिप्पणियों

स्वीकार्य यूआरआई उदाहरण:

"http://www.example.com/image.png" // from Web
"file:///mnt/sdcard/image.png" // from SD card
"file:///mnt/sdcard/video.mp4" // from SD card (video thumbnail)
"content://media/external/images/media/13" // from content provider
"content://media/external/video/media/13" // from content provider (video thumbnail)
"assets://image.png" // from assets
"drawable://" + R.drawable.img // from drawables (non-9patch images)

यूनिवर्सल इमेज लोडर को इनिशियलाइज़ करें

  1. निम्न निर्भरता build.gradle फ़ाइल में जोड़ें:

    compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
    
  2. AndroidManifest.xml फ़ाइल में निम्न अनुमतियाँ जोड़ें:

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    
  3. यूनिवर्सल इमेज लोडर को इनिशियलाइज़ करें। यह पहले उपयोग से पहले किया जाना चाहिए:

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

    पूर्ण कॉन्फ़िगरेशन विकल्प यहां मिल सकते हैं ।

मूल उपयोग

  1. एक छवि लोड, एक बिटमैप में डिकोड, और एक में बिटमैप प्रदर्शित ImageView (या किसी अन्य दृश्य जो औजार ImageAware इंटरफेस):

    ImageLoader.getInstance().displayImage(imageUri, imageView);
    
  2. एक छवि लोड करें, इसे बिटमैप में डिकोड करें, और बिटमैप को कॉलबैक पर लौटें:

    ImageLoader.getInstance().loadImage(imageUri, new SimpleImageLoadingListener() {
        @Override
        public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
            // Do whatever you want with the bitmap.
        }
    });
    
  3. एक छवि लोड करें, इसे बिटमैप में डिकोड करें और बिटमैप को समकालिक रूप से लौटाएं:

    Bitmap bmp = ImageLoader.getInstance().loadImageSync(imageUri);
    


Modified text is an extract of the original Stack Overflow Documentation
के तहत लाइसेंस प्राप्त है CC BY-SA 3.0
से संबद्ध नहीं है Stack Overflow