I’m new to android,I have an activity class which fetches Json string from url and convert Json array into an object.I’m getting the objects parsed however the image is returned as textview which is not what I want.
Trying to find a solution I have looking into [here] but this is only giving me the drawable icon not the image I need.Any help or advice will be gratefull
Below is my code.
ListAdapter adapter = new SimpleAdapter(this, List,
R.layout.list,
new String[] {TAG_PHOTOS }, new int[] {
R.id.image});
setListAdapter(adapter);
// selecting single ListView item
final ListView lv = getListView();
// Launching new screen on Selecting Single ListItem
lv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
ImageView photoThumbnailUrl = ((ImageView)
view.findViewById(R.id.image));
Bitmap bMap = BitmapFactory.decodeResource(getResources(),
R.drawable.ic_launcher);
Bitmap bMapScaled = Bitmap.createScaledBitmap(bMap, 150, 100, true);
photoThumbnailUrl.setImageBitmap(bMapScaled);
photoThumbnailUrl.setImageResource(R.drawable.ic_launcher);
photoThumbnailUrl.getDrawable();
System.out.println(photoThumbnailUrl);
lv.addView(photoThumbnailUrl);
}
});
To use imageview in android, you need to customize adapter. and I would recommend you to use LazyAdapter as, you would need this in some time.
http://codehenge.net/blog/2011/06/android-development-tutorial-asynchronous-lazy-loading-and-caching-of-listview-images/