android volley failed to load images -


i want timeline of app facebook followed tutorial.

the timeline works fine volley failed load profile pic , post image .

here project structure

public class feedlistadapter extends baseadapter { private activity activity; private layoutinflater inflater; private list<feeditem> feeditems; imageloader imageloader = appcontroller.getinstance().getimageloader();  public feedlistadapter(activity activity, list<feeditem> feeditems) {     this.activity = activity;     this.feeditems = feeditems; }  @override public int getcount() {     return feeditems.size(); }  @override public object getitem(int location) {     return feeditems.get(location); }  @override public long getitemid(int position) {     return position; }  @override public view getview(int position, view convertview, viewgroup parent) {      if (inflater == null)         inflater = (layoutinflater) activity                 .getsystemservice(context.layout_inflater_service);     if (convertview == null)         convertview = inflater.inflate(r.layout.feed_item, null);      if (imageloader == null)         imageloader = appcontroller.getinstance().getimageloader();      textview name = (textview) convertview.findviewbyid(r.id.name);     textview timestamp = (textview) convertview             .findviewbyid(r.id.timestamp);     textview statusmsg = (textview) convertview             .findviewbyid(r.id.txtstatusmsg);     textview url = (textview) convertview.findviewbyid(r.id.txturl);     networkimageview profilepic = (networkimageview) convertview             .findviewbyid(r.id.profilepic);     feedimageview feedimageview = (feedimageview) convertview             .findviewbyid(r.id.feedimage1);      feeditem item = feeditems.get(position);      name.settext(item.getname());      // converting timestamp x ago format     charsequence timeago = dateutils.getrelativetimespanstring(             long.parselong(item.gettimestamp()),             system.currenttimemillis(), dateutils.second_in_millis);     timestamp.settext(timeago);      // chcek empty status message     if (!textutils.isempty(item.getstatus())) {         statusmsg.settext(item.getstatus());         statusmsg.setvisibility(view.visible);     } else {         // status empty, remove view         statusmsg.setvisibility(view.gone);     }      // checking null feed url     if (item.geturl() != null) {         url.settext(html.fromhtml("<a href=\"" + item.geturl() + "\">"                 + item.geturl() + "</a> "));          // making url clickable         url.setmovementmethod(linkmovementmethod.getinstance());         url.setvisibility(view.visible);     } else {         // url null, remove view         url.setvisibility(view.gone);     }      // user profile pic     profilepic.setimageurl(item.getprofilepic(), imageloader);      // feed image     if (item.getimge() != null) {         feedimageview.setimageurl(item.getimge(), imageloader);         feedimageview.setvisibility(view.visible);         feedimageview                 .setresponseobserver(new feedimageview.responseobserver() {                     @override                     public void onerror() {                     }                      @override                     public void onsuccess() {                     }                 });     } else {         feedimageview.setvisibility(view.gone);         log.i("null","image");     }      return convertview; } 

}

if need more info code me please notify me in advance.

try this

1.you can use glide library load image url below code can in simple way

compile dependency inside gradle file

compile 'com.github.bumptech.glide:glide:4.0.0-rc0' 

than load image this

glide.with(homeclass.this)             .load(url)             .into(imageview); 

2 .try if dont want use third party library

 new downloadimage(imamgeview).execute(url); 

create async task

public class downloadimage extends asynctask<string, void, bitmap> { imageview bmimage;  public downloadimage(imageview bmimage) {     this.bmimage = (imageview ) bmimage; }  protected bitmap doinbackground(string... urls) {     string urldisplay = urls[0];     bitmap micon11 = null;     try {         inputstream in = new java.net.url(urldisplay).openstream();         micon11 = bitmapfactory.decodestream(in);     } catch (exception e) {         log.d("error", e.getstacktrace().tostring());      }     return micon11; }  protected void onpostexecute(bitmap result) {     bmimage.setimagebitmap(result); } } 

3 use picasso image loading in imageview. dependency inside gradle file

compile 'com.squareup.picasso:picasso:2.5.2' 

than load image in image view this

picasso.with(activity).load(img_url).nofade().into(imageview); 

i hope work in case


Comments

Popular posts from this blog

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -