In general, when using the Simpleadapter adapter, the picture resources that we want to display are local resources within the program, and are represented in the form of resource IDs.
Map.put ("img", r.drawable.i3);
But sometimes we need to use this adapter to display the remote picture on the Internet, how to display it directly? The method is to implement the Viewbinder () interface, which defines the matching relationship between the data and the view.
Adapter=NewSimpleadapter ( This, data,//Data SourceR.layout.activity_new_product_item,//Show Layout NewString[] {"Itemimage", "Itemtext", "Itemnewprice", "Itemoldprice" }, New int[] {r.id.itemimage, r.id.itemtext, R.id.newprice, r.id.oldprice}); Adapter.setviewbinder (NewViewbinder () {@Override Public Booleansetviewvalue (view view, Object data, String textrepresentation) {if(ViewinstanceofImageView) & (datainstanceofBitmap)) {ImageView IV=(ImageView) view; Bitmap BM=(Bitmap) data; Iv.setimagebitmap (BM); return true; } return false; } }); Gridview.setadapter (adapter);
Android uses Simpleadapter to display bitmap pictures directly