i am get the images from mysql database to my android mobile . i want to display image along with names enter code here Main.java
JSONArray json = jArray.getJSONArray("names");
list=(ListView)findViewById(R.id.list);
adapter=new ImageAdapter(this, json);
list.setAdapter(adapter);
Image adapter.java
public class ImageAdapter extends BaseAdapter {
Bitmap bmp;
private static LayoutInflater inflater = null;
private ImageView[] mImages;
String[] itemimage;
String itemname;
HashMap<String, String> map = new HashMap<String, String>();
public ImageAdapter(Context context, JSONArray imageArrayJson) {
this.mImages = new ImageView[imageArrayJson.length()];
String qrimage;
try {
for (int i = 0; i < imageArrayJson.length(); i++) {
JSONObject image = imageArrayJson.getJSONObject(i);
qrimage = image.getString("itemimage");
itemname = image.getString("itemname");
map.put("itemname", image.getString("itemname"));
System.out.println(itemname);
byte[] qrimageBytes = Base64.decode(qrimage.getBytes());
bmp = BitmapFactory.decodeByteArray(qrimageBytes, 0,
qrimageBytes.length);
int width = 100;
int height = 100;
Bitmap resizedbitmap =
Bitmap.createScaledBitmap(bmp,width,
height, true);
Log.e("Image Height", " Height = " + bmp.getHeight()
+ " , Width = " + bmp.getWidth());
mImages[i] = new ImageView(context);
mImages[i].setImageBitmap(resizedbitmap);
mImages[i].setScaleType(ImageView.ScaleType.FIT_START);
}
} catch (Exception e) {
// TODO: handle exception
}
}
public int getCount() {
return mImages.length;
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
return mImages[position];
}
}
my xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ListView
android:id="@+id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</LinearLayout>
the above code i can able to view the images from the mysql database from server to my android mobile. i want display itemimages along with item names in list view in base adapter get view i can display all images.like that i want display all item names. i print itemnames it print all names from database . i want display images and names in list view