我有一個類,在數據庫中得到兩個字段(名稱和圖像),並設置名稱文本瀏覽和圖片設置爲圖像視圖 現在我有形象問題,應該怎麼用圖像名稱設置圖像圖像視圖存儲在數據庫中? 請幫幫我!如何設置圖像的圖像視圖的名稱,存儲在數據庫中的Android?
我的源代碼:
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;
}
}
通過「映像名稱'你的意思是圖像文件存儲位置的路徑? – JonasCz 2015-03-02 20:06:57
不只是存儲圖像的名字,並把圖像繪製 – 2015-03-02 20:16:12