12
ich benutze Arrayadapter für meine Listview und ich möchte DownloadManager darin verwenden. aber das Array Adapter nicht weiß, diese Zeile:wie man DownloadManager in ArrayAdapter verwendet
DownloadManager download =(DownloadManager) getSystemService(DOWNLOAD_SERVICE);
so wie kann ich mit diesem im meine Adapter-Klasse, dass, wenn der Benutzer das Bild herunterladen berühren Start
meine Adapterklasse:
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 FROM list WHERE 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;
}
DownloadManager download = (DownloadManager) context.getSystemService (Kontext.DOWNLOAD_SERVICE); – hamedjj