i have a class that get two field(name and image) in database and set name to Text View and image set to image view now i have problem with image , how to should set image to image view by image name that stored in database ? Please Help me!
my source code:
public class ListMovie extends BaseAdapter {
private Resources res = null;
private Activity activity;
private ArrayList<HashMap<String, String>> data;
private LayoutInflater inflate;
ViewHolder holder;
public ListMovie(Activity a, ArrayList<HashMap<String, String>> d) {
// TODO Auto-generated constructor stub
activity = a;
data = d;
inflate = (LayoutInflater) activity
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return data.size();
}
@Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return position;
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}
@Override
public View getView(int arg0, View view, ViewGroup arg2) {
// TODO Auto-generated method stub
View v1 = view;
if (v1 == null) {
v1 = inflate.inflate(R.layout.item, null);
holder = new ViewHolder();
holder.txt_name = (TextView) v1.findViewById(R.id.item_name);
holder.img = (ImageView) v1.findViewById(R.id.item_img);
v1.setTag(holder);
} else {
holder = (ViewHolder) v1.getTag();
}
HashMap<String, String> song = new HashMap<String, String>();
song = data.get(arg0);
holder.txt_name.setText(song.get("name"));
return v1;
}
static class ViewHolder {
TextView txt_name;
ImageView img;
}
}
Aucun commentaire:
Enregistrer un commentaire