I am trying to select multiple items from a listview and when the items are selected they are each given a unique id.
This is my adapter class so far:
public class CallDisplay extends ArrayAdapter<String>{
private final Context context;
private final List values;
public CallDisplay(Context context, List values) {
super(context, R.layout.product_list, values);
this.context = context;
this.values = values;
}
class DownloadImageTask extends AsyncTask<String, Void, Bitmap> {
ImageView bmImage;
public DownloadImageTask(ImageView bmImage) {
this.bmImage = bmImage;
}
@Override
protected void onPreExecute() {
// TODO Auto-generated method stub
super.onPreExecute();
}
protected Bitmap doInBackground(String... urls) {
String urldisplay = urls[0];
Bitmap mIcon11 = null;
try {
InputStream in = new java.net.URL(urldisplay).openStream();
mIcon11 = BitmapFactory.decodeStream(in);
} catch (Exception e) {
Log.e("Error", e.getMessage());
e.printStackTrace();
}
return mIcon11;
}
@Override
protected void onPostExecute(Bitmap result) {
super.onPostExecute(result);
bmImage.setImageBitmap(result);
}
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View rowView = inflater.inflate(R.layout.product_list, parent, false);
TextView Name = (TextView) rowView.findViewById(R.id.name);
TextView Desc = (TextView) rowView.findViewById(R.id.description);
TextView Price = (TextView)rowView.findViewById(R.id.price);
TextView ebaylink = (TextView)rowView.findViewById(R.id.elink);
ImageView imageView = (ImageView) rowView.findViewById(R.id.prod_image);
TextView id = (TextView)rowView.findViewById(R.id.id);
id.setText(((HashMap<String, String>)values.get(position)).get("id"));
Name.setText(((HashMap<String, String>)values.get(position)).get("name"));
Desc.setText(((HashMap<String, String>)values.get(position)).get("desc"));
Price.setText(((HashMap<String, String>)values.get(position)).get("price"));
ebaylink.setText(((HashMap<String, String>)values.get(position)).get("elink"));
new DownloadImageTask(imageView).execute(((HashMap<String, String>)values.get(position)).get("photo"));
//imageView.setImageBitmap("http://www.digitaltrends.com/wp-content/uploads/2013/04/Samsung-Galaxy-6-3-sample-image-3.jpg");
return rowView;
}
}
How can I edit it so that when multiple items are selected they are each given a unique id number? Thank you