I am not able to find out how to set a picture as setImageResource()
. Currently I can easily add from res/drawable
like this:
In ListViewAdapter:
imageView = (ImageView) rowView.findViewById(R.id.listImageView);
imageView.setImageResource((int) getItemId(position));
In ViewAdapter:
public class ViewAdapter extends BaseAdapter {
class Item {
public long id;
public String name;
public Item(long id, String name) {
this.id = id;
this.name = name;
}
}
public ViewAdapter(Context c) {
mContext = c;
mItems = new ArrayList<Item>();
mItems.add(new Item(R.drawable.mercury,"Mercury"));
mItems.add(new Item(R.drawable.mercury,"Mercury"));
mItems.add(new Item(R.drawable.mercury,"Mercury")); ...
So, how can I add a picture from a path? For example, say "/storage/emulated/Photos/Italy.jpg"
? Again, I can store them in res/drawable
and add them, but need a way to add it from file. Tried different ways, but still can't find out how to do it.
Thanks a lot!