java - non static variable cannot be referenced from a static context in Adapter -


i using base adapter displaying image in grid view. working fine when images fixed image_urls directly try geting url list , assign image_urls shows non static variable cannot referenced static context. don't know how solve issue. please solve issue

public class imagegridfragment extends abslistviewbasefragment {   public static final int index = 1;      string description="";      arraylist<string> img = new arraylist<string>();  @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) {     view rootview = inflater.inflate(r.layout.fr_image_grid, container, false);     listview = (gridview) rootview.findviewbyid(r.id.grid);             img.clear();         bundle bundle = this.getarguments();          description = bundle.getstring("description");         string[] separated= description.split(",");     for(int i=0;i<separated.length;i++)     {         img.add(separated[i]);     }      imagegalleryfragment.imageloader.init(imageloaderconfiguration.createdefault(getactivity()));     ((gridview) listview).setadapter(new imageadapter(getactivity()));     listview.setonitemclicklistener(new onitemclicklistener() {         @override         public void onitemclick(adapterview<?> parent, view view, int position, long id) {             startimagepageractivity(position);         }     });     return rootview; }     private static class imageadapter extends baseadapter {          string[] image_urls =  img.toarray(new string[img.size()]);      private layoutinflater inflater;      private displayimageoptions options;      imageadapter(context context) {         inflater = layoutinflater.from(context);          options = new displayimageoptions.builder()                 .showimageonloading(r.drawable.ic_stub)                 .showimageforemptyuri(r.drawable.ic_empty)                 .showimageonfail(r.drawable.ic_error)                 .cacheinmemory(true)                 .cacheondisk(true)                 .considerexifparams(true)                 .bitmapconfig(bitmap.config.rgb_565)                 .build();     }      @override     public int getcount() {         return image_urls.length;     }      @override     public object getitem(int position) {         return null;     }      @override     public long getitemid(int position) {         return position;     }      @override     public view getview(int position, view convertview, viewgroup parent) {         final viewholder holder;         view view = convertview;         if (view == null) {             view = inflater.inflate(r.layout.item_grid_image, parent, false);             holder = new viewholder();             assert view != null;             holder.imageview = (imageview) view.findviewbyid(r.id.image);             holder.progressbar = (progressbar) view.findviewbyid(r.id.progress);             view.settag(holder);         } else {             holder = (viewholder) view.gettag();         }          imageloader.getinstance()                 .displayimage(image_urls[position], holder.imageview, options, new simpleimageloadinglistener() {                     @override                     public void onloadingstarted(string imageuri, view view) {                         holder.progressbar.setprogress(0);                         holder.progressbar.setvisibility(view.visible);                     }                      @override                     public void onloadingfailed(string imageuri, view view, failreason failreason) {                         holder.progressbar.setvisibility(view.gone);                     }                      @override                     public void onloadingcomplete(string imageuri, view view, bitmap loadedimage) {                         holder.progressbar.setvisibility(view.gone);                     }                 }, new imageloadingprogresslistener() {                     @override                     public void onprogressupdate(string imageuri, view view, int current, int total) {                         holder.progressbar.setprogress(math.round(100.0f * current / total));                     }                 });          return view;     } }  static class viewholder {     imageview imageview;     progressbar progressbar;     } } 

change class private static "private class imageadapter".


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -