I want something like this:
How to deal the result?
I want to diplay contact name + contact image and be able to multi select them.
What i have got so far: the arrayclass
public class ContactList extends ArrayAdapter {
private final Activity activity;
private final List stocks;
public ContactList(Activity activity, List objects) {
super(activity, R.layout.contact_row, objects);
this.activity = activity;
this.stocks = objects;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View rowView = convertView;
ContactStockView sv = null;
if (rowView == null) {
// Get a new instance of the row layout view
LayoutInflater inflater = activity.getLayoutInflater();
rowView = inflater.inflate(
R.layout.contact_row, null);
// Hold the view objects in an object,
// so they don't need to be re-fetched
sv = new ContactStockView();
sv.name = (TextView) rowView.findViewById(R.id.contact_name);
sv.Image = (ImageView) rowView.findViewById(R.id.imageView1);
sv.number = (TextView) rowView.findViewById(R.id.contact_number);
// Cache the view objects in the tag,
// so they can be re-accessed later
rowView.setTag(sv);
} else {
sv = (ContactStockView) rowView.getTag();
}
// Transfer the stock data from the data object
// to the view objects
contact currentStock = (contact) stocks.get(position);
sv.name.setText(currentStock.getName());
sv.number.setText(currentStock.getNumber());
sv.Image.setImageBitmap(currentStock.getPicture());
// TODO Auto-generated method stub
return rowView;
}
protected static class ContactStockView {
protected TextView name;
protected TextView number;
protected ImageView Image; }}
The Contact Class:
public class contact {
private String name;
private String number;
private Bitmap picture;
// your current code goes here
public void setPicture(Bitmap picture) {
this.picture = picture;
}
public Bitmap getPicture() {
return picture;
}
public contact(String name, String number,Bitmap photo) {
this.name = name;
this.number = number;
this.picture = photo;
}
public void setName(String name) {
this.name = name;
}
public void setNumber(String number) {
this.number = number;
}
public String getName() {
return this.name;
}
public String getNumber() {
return this.number;
}}
Aucun commentaire:
Enregistrer un commentaire