Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9052671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T13:14:10+00:00 2026-06-16T13:14:10+00:00

Google has released the YouTube api for Google. In that api is a YouTubeThumbnailView

  • 0

Google has released the YouTube api for Google. In that api is a YouTubeThumbnailView to display thumbnails of a movie.
I want to display the thumbnails in a ListView. I have made a adapter to make the views. But I’m not sure how to handle this.

In the getView of my ListView-adapter I inflate a layout which include the YouTubeThumbnailView. According to the documentation (https://developers.google.com/youtube/android/player/reference/com/google/android/youtube/player/YouTubeThumbnailView) I should call the initialize method.

I’m wondering if I need to call the initialize method one time or also call this if the view is re-used by the ListView? There is no way to check if the YouTubeThumbnailView is already initialized? So I guess I should call it multiple times. But I have no idea if that is allowed?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T13:14:11+00:00Added an answer on June 16, 2026 at 1:14 pm

    You should only call it once, but save a reference to the loader once it’s initialized. One way to deal with this is to keep a map from View to YouTubeThumbnailLoader. In getView, there are 3 cases:

    1. The view is new and needs to be initialized.
    2. The view is already initialized and we have a reference to the loader.
    3. The view is currently initializing.

    In case 1 and 3, you need to remember what the loader should do when it’s initialized. You can e.g. save the video id in the tag of the view.

    Example code:

    Map<View, YouTubeThumbnailLoader> loaders;
    
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      View view = convertView;
      String videoId = getVideoId(position);
    
      if (view == null) {
        // Case 1 - We need to initialize the loader
        view = inflater.inflate(..., parent, false);
        YouTubeThumbnailView thumbnail = (YouTubeThumbnailView) view.findViewById(R.id.thumbnail);
        thumbnail.setTag(videoId);
        thumbnail.initialize(DeveloperKey.DEVELOPER_KEY, thumbnailListener);
      } else {
        YouTubeThumbnailView thumbnail = (YouTubeThumbnailView) view.findViewById(R.id.thumbnail);
        YouTubeThumbnailLoader loader = loaders.get(thumbnail);
        if (loader == null) {
          // Case 3 - The loader is currently initializing
          thumbnail.setTag(videoId);
        } else {
          // Case 2 - The loader is already initialized
          thumbnail.setImageResource(R.drawable.loading_thumbnail);
          loader.setVideo(videoId);
        }
      }
      return view;
    }
    

    And in your thumbnailListener:

      @Override
      public void onInitializationSuccess(YouTubeThumbnailView view, YouTubeThumbnailLoader loader) {
        String videoId = (String) view.getTag();
        loaders.put(view, loader);
        view.setImageResource(R.drawable.loading_thumbnail);
        loader.setVideo(videoId);
      }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The Google App Engine has previously released a Search API, that allows you to
Now that Google Earth has been released for Android 2.1, does anyone know what,
It is known that google has best searching & indexing algorithm. The also have
Now that Google has officially released their +1 button for websites , I'd like
In Android API 11+, Google has released a new class called Fragment . In
I was wondering if it is possible that Google has a feature to view
I have recently indexed my website. Google has indexed the main site as: www.site.com/?ref=old
Google guice has a built-in logger binding . But what if I want to
I remember I stumbled upon a page once that said Microsoft has released an
I went to SDK manager today and found google has released GCM update verison

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.