android - Getting red flag when setting simpleAdapter in fragment (onPostExecute) -


i'm trying parse json data (image url) gridview. i'm able data json when tried set simpleadapter display them on gridview got redflag stating:

the constructor simpleadapter(salesfragment, list>, int, string[], int[]) undefined.

i googled couldn't find solution. please help...

salesfragment.java

    public class salesfragment extends fragment {         gridview gridview;          @override         public view oncreateview(layoutinflater inflater, viewgroup container,                 bundle savedinstancestate) {             view gv = inflater.inflate(r.layout.hot_sales, null);             gridview = (gridview) gv.findviewbyid(r.id.grid_view);             //gridview.setadapter(new imageadapter(this, getactivity()));             bindgridview();             return gv;         }          public void bindgridview() {             new myasynctask(getactivity(),gridview).execute("");         }          class myasynctask extends asynctask<string, string, string> {             gridview mgridview;             activity mcontext;             response response;            public  myasynctask(activity context,gridview gview) {              this.mgridview=gview;              this.mcontext=context;             }             protected string doinbackground(string... params)  {                      try{                            // here getting json data using gson                         } catch (filenotfoundexception e) {                            e.printstacktrace();                         } catch (@suppresswarnings("hiding") ioexception e){                            e.printstacktrace();                         }                 }else{                     system.out.println("error");                 }                 return null;                 }             @override            protected void onpostexecute(string result) {                   super.onpostexecute(result);                  list<hashmap<string,string>> alist1 = new arraylist<hashmap<string,string>>();                  for(sales sales : this.response.sales){                     hashmap<string, string> hm = new hashmap<string,string>();                      if (sales.getcategories1().contains("12")){                     //getting data                         }                         alist1.add(hm);                     }                 }                  simpleadapter adapter = new simpleadapter(salesfragment.this, alist1,                         r.layout.grid_sales, new string[] { "shop_image"},new int[] { r.id.sale_image });                 // updating gridview                 gridview.setadapter(adapter);            } } 

you should change this:

simpleadapter adapter = new simpleadapter(salesfragment.this, alist1, r.layout.grid_sales, new string[] { "shop_image"},new int[] { r.id.sale_image }); 

with

simpleadapter adapter = new simpleadapter(getactivity(), alist1, r.layout.grid_sales, new string[] { "shop_image"},new int[] { r.id.sale_image }); 

if have made context of fragment can use 1 instead of getactivity().


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

IIS->Tomcat Redirect: multiple worker with default -