我想從字符串獲取ImageView到picture.setImageResource();
我使用字符串來整數變化,它不顯示在GridView中。如何獲取圖像大小和setImageView?如何設置圖像資源?
Menu.java
public class Menu {
private Integer id;
private String menuImage;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getMenuImage() {
return menuImage;
}
public void setMenuImage(String menuImage) {
this.menuImage = menuImage;
}
MyAdapter.java
public class MyAdapter extends BaseAdapter {
List<Menu> mItems = new ArrayList<Item>(); // from server
LayoutInflater mInflater;
public MenuGridViewAdapter(Context context, List<Menu> menuList) {
mInflater = LayoutInflater.from(context);
this.menuList = menuList;
}
@Override
public int getCount() {
return mItems.size();
}
@Override
public Menu getItem(int i) {
return mItems.get(i);
}
@Override
public long getItemId(int i) {
return 0;
}
@Override
public View getView(int i, View view, ViewGroup viewGroup) {
View v = view;
ImageView picture;
TextView name;
if (v == null) {
v = mInflater.inflate(R.layout.grid_item, viewGroup, false);
v.setTag(R.id.picture, v.findViewById(R.id.picture));
}
picture = (ImageView) v.getTag(R.id.picture);
Item item = getItem(i);
picture.setImageResource(); //
return v;
}
你好,@Simranjeet辛格圖像被來自服務器內部列表