java - Constructor is undefined in ArrayAdapter -


i trying populate listview control in android app. have looked @ many code samples , seem suggest doing way. however, when try implement following error:

the constructor arrayadapter(mainactivity.readjsontask, int, arraylist) undefined

    protected void onpostexecute(string result){         try{             listview lv = (listview)findviewbyid(r.id.lstitems);             jsonobject jsonobj = new jsonobject(result);              arraylist<string> items = new arraylist<string>();             iterator<string> looper = jsonobj.keys();             while(looper.hasnext()){                 string key = looper.next();                 items.add(jsonobj.get(key).tostring());             }                            adapter = new arrayadapter<string>(this, android.r.layout.simple_list_item_1, items);             lv.setadapter(adapter);          }catch(exception ex){             log.d("readadscendjsontask", ex.getlocalizedmessage());         }     } 

what wrong here? thanks!

it seems piece of code inner class. , in such case this refers inner class instead of mainactivity. changing context parameter mainactivity.this arrayadapter should fix error.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -