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

  • SEARCH
  • Home
  • 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 7695951
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T21:39:59+00:00 2026-05-31T21:39:59+00:00

I am gathering data from youtube’s gdata API and would like to use the

  • 0

I am gathering data from youtube’s gdata API and would like to use the video’s thumbnail. I already have the urls for each of the thumbnails, however I am not able to get the images to show up in my listview. The bitmap is currently not returning null, however I am not able to call the imageview.setImageBitmap(bitmap) method with my current implementation (that I know of?). Please help if you know of a better way to do this! Thanks

public class ResultListActivity extends ListActivity {

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    String searchquery = null;
    Intent starter = getIntent();
    Bundle extras = starter.getExtras();
    if (extras != null) {
        searchquery = extras.getString("search");
    }        
    final String URL = "http://gdata.youtube.com/feeds/api/videos?max-results=5&alt=json&author=user&q=" + searchquery;
    final ArrayList<HashMap<String, ?>> data = new ArrayList<HashMap<String, ?>>();
    final QueryYoutube query;       

    query = new QueryYoutube();
    boolean success = query.searchYoutube(URL); 

    if (success == false) {
        Toast.makeText(this, "Sorry, no matching results found.", Toast.LENGTH_SHORT).show();
        Intent intent = new Intent(ResultListActivity.this, YoutubeActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
        startActivity(intent);
        finish();
    } 

    int size = query.getNumberResults();
    HashMap<String, Object> row  = new HashMap<String, Object>();

    for (int i=0; i<size; i++) {
        Bitmap bitmap = null;
        Drawable d = null;          
        try {                   
            bitmap = BitmapFactory.decodeStream((InputStream)new URL(query.getThumbnail(i)).getContent());
            bitmap.setDensity(Bitmap.DENSITY_NONE);
            d = new BitmapDrawable(bitmap);
        } catch (MalformedURLException e) {
          e.printStackTrace();
        } catch (IOException e) {
          e.printStackTrace();
        }

        row  = new HashMap<String, Object>();
        row.put("Thumbnail", d);            
        row.put("Title", query.getTitle(i));
        row.put("Description", query.getDescription(i));
        data.add(row);
    }

    SimpleAdapter adapter = new SimpleAdapter(this, data, R.layout.row,
              new String[] {"Thumbnail","Title","Description"},
              new int[] {R.id.thumb, R.id.title, R.id.description});
    setListAdapter(adapter);

    ListView lv = getListView();
    lv.setTextFilterEnabled(true);

    lv.setOnItemClickListener(new OnItemClickListener() {

        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Intent lVideoIntent = new Intent(null, Uri.parse("ytv://"+query.getVideoID(position)), 
                   ResultListActivity.this, OpenYouTubePlayerActivity.class);
            startActivity(lVideoIntent);               
        }
    });

}
}
  • 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-05-31T21:40:00+00:00Added an answer on May 31, 2026 at 9:40 pm

    The way I would recommend doing this is that you should extend the ArrayAdapter class then in the getView method you fire off an AsyncTask to download the thumbnail in thread outside of the UI thread, then set the bitmap to the imageview in onPostExecute.

    You should use something like HttpUrlConnection to get the InputStream for the image to decode into a Bitmap. If you are unsure about the dimensions of the Bitmap it is important that you check the size of the image before you actually create a Bitmap object that causes an OutOfMemoryError so beforehand set BitmapFactory.Options inJustDecodeBounds to true and then get the dimensions of the image then choose a sufficient inSampleSize and decode again to retrieve a Bitmap that is not too large.

    You should also have some sort of Bitmap cache so that you don’t have to always retrieve from the web.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have my winform application gathering data using databinding. Everything looks fine except that
I'm having issues gathering data using JSON on the Songkick API. I'm really new
I am gathering data from a website. I estimate to get 10.000 datapoints (time
The Story There is a writer thread, periodically gathering data from somewhere (in real-time,
I'm developing an application for data gathering from Internet and creating charts and plots
I'm working with gathering data from a biological monitoring system. They need to know
I have a question that pertains to gathering events from tables in a calendar
I mean how google analytics gathering data from client side. My guess is that
I am writing an HTML5 application that is gathering data from a few different
I am going to implement an application that is gathering data from Android device.

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.