android - how to use DownloadManager in ArrayAdapter -


i'm using arrayadapter listview , want use downloadmanager in it. array adapter doesn't know line :

downloadmanager download =(downloadmanager) getsystemservice(download_service); 

so how can use im adapter class when user touch image download starting

my adapter class :

public class myadapter extends arrayadapter<string>{      private final context context;     private final string[] values;     context b;      public myadapter(context context, string[] values) {         super(context, r.layout.item, values);         this.context = context;         this.values = values;         b= (context) context;     }      @override     public view getview(final int position, view convertview, viewgroup parent) {         layoutinflater inflater = (layoutinflater) context.getsystemservice(context.layout_inflater_service);                view rootview = inflater.inflate(r.layout.item, parent, false);          textview tv1 = (textview)rootview.findviewbyid(r.id.txt_name);         textview tv2 = (textview)rootview.findviewbyid(r.id.txt_numer);         imageview img = (imageview) rootview.findviewbyid(r.id.imageview1);          mydatabase mydatabase = new mydatabase(context);         sqlitedatabase mydb = mydatabase.getreadabledatabase();         cursor cur = mydb.rawquery("select name,category,url list id='"+values[position]+"'", null);         if (cur != null) {             cur.movetofirst();}           tv1.settext(cur.getstring(cur.getcolumnindex("name")));              tv2.settext(cur.getstring(cur.getcolumnindex("category")));           return rootview;     } 

you need pass context also: edit:

downloadmanager download = (downloadmanager) context.getsystemservice(context.download_service); 

Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -