android - ListView Item not loading images from url -


i have custom baseadapter loading images custom listview of sorts urls using async tasks images not showing. here adapter:

private class horizontaladapter extends baseadapter{          public horizontaladapter() {             super();             final checkpoint current = localcheckpoints[checkpointposition];             urls[0] = current.getgallery()[0].geturl();             urls[1] = current.getyoutube();             urls[2] = current.getsoundcloud();         }          @override         public int getcount() {             return 3;         }          @override         public object getitem(int position) {             return urls[position];         }          @override         public long getitemid(int position) {             return position;         }          @override         public view getview(int position, view convertview, viewgroup parent) {              string urltoload = urls[position];              if(convertview == null){                 convertview = layoutinflater.from(getactivity()).inflate(r.layout.horizontal_listview_item,parent,false);             }              imageview imageview = (imageview)convertview.findviewbyid(r.id.cp_image);             framelayout container = (framelayout)convertview.findviewbyid(r.id.youtubeshower);             button playbutton = (button)convertview.findviewbyid(r.id.playstop);              playbutton.setvisibility(view.visible);              if(position == 0){                 log.d("horizontalsv","loading image url: " + urltoload);                 new loadimage(imageview).execute(urltoload);                 //container.setvisibility(view.visible);                 imageview.setvisibility(view.visible);               }             else if(position == 1){                 container.setvisibility(view.visible);                 imageview.setvisibility(view.invisible);                 string videoid = extractytid(urltoload);                 playyoutubevidefragment youtubefrag = playyoutubevidefragment.newinstance(videoid);                 mycontext.getsupportfragmentmanager().begintransaction().replace(r.id.youtubeshower, youtubefrag).commit();              }else{                }              return convertview;         }     } 

and here xml listview item:

<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="match_parent" android:layout_height="match_parent"      >      <framelayout         android:id="@+id/youtubeshower"         android:layout_width="match_parent"         android:layout_height="288dp"         android:layout_alignparenttop="true"         android:layout_centerhorizontal="true"         android:layout_alignparentbottom="true">      </framelayout>      <imageview         android:layout_width="match_parent"         android:layout_height="match_parent"         android:id="@+id/cp_image"         android:layout_alignparentbottom="true"         android:layout_alignparenttop="true"         android:layout_alignparentleft="true"         android:layout_alignparentstart="true"         android:layout_alignparentright="true"         android:layout_alignparentend="true" />      <button         android:layout_width="wrap_content"         android:layout_height="87dp"         android:text="play"         android:id="@+id/playstop"         android:layout_alignparentbottom="true"         android:layout_centerhorizontal="true" /> </relativelayout> 

and here how loading images:

private class loadimage extends  asynctask<string,void,bitmap>{          imageview target;          public  loadimage(imageview imageviewtoload){             target = imageviewtoload;             if(imageviewtoload == null){                 log.e("in loadimage","imageview null");             }else{                 log.d("in loadimage","imageview there");             }         }          @override         protected bitmap doinbackground(string... params) {             string urlstring = params[0];              try {                 url url = new url(urlstring);                 try {                     bitmap bmp = bitmapfactory.decodestream(url.openconnection().getinputstream());                     return  bmp;                 }catch(ioexception e){                     log.e("ioexception",e.getmessage());                     return  null;                 }              }catch (malformedurlexception e){                 log.e("url error", "url = " + urlstring + " , error = " + e.getmessage());                 return  null;             }            }          @override         protected void onpostexecute(bitmap o) {             super.onpostexecute(o);             if(o != null){                 log.d("in loadimage","bitmap not null");                 target.setimagebitmap(o);                 //lvtest.setadapter(new horizontaladapter());             }else{                 log.e("in loadimage","bitmap null");                 target.setimagebitmap(null);                 target.setbackgroundcolor(color.white);             }         }     } 

is there reason why images not loading? bitmap returning not null in load image asynctask should work.

use picasso library, should take away problems you're having asynchronous task. http://square.github.io/picasso/


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -