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 8593049
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:53:53+00:00 2026-06-11T23:53:53+00:00

İ am using this custom adapter for showing youtube thumbnail. public class MyMedyaAdapter extends

  • 0

İ am using this custom adapter for showing youtube thumbnail.

public class MyMedyaAdapter extends SimpleAdapter {
    Context context;
    int layout;
    List<? extends Map<String, ?>> data;
    String[] from;
    int[] to;

    String resimURL = "http://img.youtube.com/vi/{0}/0.jpg";

    public MyMedyaAdapter(Context context, List<? extends Map<String, ?>> data, int resource, String[] from, int[] to) {
        super(context, data, resource, from, to);
        this.context = context;
        this.layout = resource;
        this.data = data;
        this.from = from;
        this.to = to;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        // TODO Auto-generated method stub
        LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View rowView = inflater.inflate(layout, parent, false);

        TextView metin = (TextView) rowView.findViewById(R.id.row_medya_text);

        String baslik = data.get(position).get(from[0]) + "";
        baslik = baslik.replace(".pdf", "");

        metin.setText(baslik);

        if (from.length > 1) {
            final ImageView resim = (ImageView) rowView.findViewById(R.id.row_medya_image);

            final int p2 = position;

            String resimID = data.get(p2).get(from[1])+"";

            String rowImage = resimURL.replace("{0}", resimID);
            try {
                Bitmap bitmap = BitmapFactory.decodeStream((InputStream)new URL(rowImage).getContent());
                resim.setImageBitmap(bitmap);

            } catch (Exception e) {
                // TODO: handle exception
            }
        }

        return rowView;
    }
}

adding adapter to listview with this code;

public class VideoThered extends AsyncTask<Void, Void, MyMedyaAdapter> {

        @Override
        protected MyMedyaAdapter doInBackground(Void... params) {

            List<HashMap<String, String>> response = new ArrayList<HashMap<String, String>>();

            try {
                                //JSON request
                response = new JsonHelper().GetVideoEntitys();
            } catch (Exception e) {
                response = null;
            }

            if (response != null) {
                adapter = new MyMedyaAdapter(ctx, response, R.layout.row_medya, from, to);
            }
            else
            {
                adapter = null;
            }
            return adapter;
        }

        @Override
        protected void onPostExecute(MyMedyaAdapter result) {
            if (result != null) {
                                //StrictMode$AndroidBlockGuardPolicy.onNetwork() error with this line on honeycomb
                listVideolar.setAdapter(adapter);
            }
        }


    }

i am getting /StrictMode$AndroidBlockGuardPolicy.onNetwork() error.

How can i manage to show row images from web and not getting this error?

i am using listview main data from AsyncTask.
in this data list, each item has a unique youtube video id. with this id i am getting video thumbnails from web. but on my custom adapter did not use AsyncTask. i know that’s the problem.
But how can i manage to my custom adaptor to use AsyncTask?

  • 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-11T23:53:55+00:00Added an answer on June 11, 2026 at 11:53 pm

    You are getting the error because you do network access in the UI thread. This is considered bad, because network access takes a long time and thus blocks the UI.

    To solve this, you can write an AsyncTask that pulls the data from the net within its doInBackground method and then in onPostExecute fills the view with the bitmap/drawable.
    I think the Android documentation has an example for this scenario, but I can’t find it right now.

    You can also have a look at this source code snippet, DownloadUserImageTask from my Zwitscher app; the url is retrieved from the passed User object. The picture is then added to the view in

    userPictureView.setImageBitmap(result);   
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using this Custom Adapter for my ListView: public class SideMenuAdapter extends BaseAdapter
To use custom layout file in my app I'm using this following code, set
I am using a custom adapter with a ListView and using a custom layout
I'm getting am AndroidRuntimeException when I click the menuButton using this custom ListView Adapter:
I have a custom adapter extended from the SimpleCursorAdapter. Using this I'm binding a
I am using a custom Adapter class. And retrieving data from database using cursor.
i have created a My custom listActivty by extending ListActivity like this. public class
I am using this code to Implement the ListView with section: public class ListSample
I am using a listview with a custom adapter in a layout. Now i
I'm trying to delete items from a ListView using a custom adapter which extends

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.