来自php的Android动态图库gridview

I have a working GalleryActivity with an ImageAdapter. It display on the screen a gridview (3 columns) loading image from a drawable array.

public class GalleryActivity extends Activity {

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.grid_layout);

    GridView gridView = (GridView) findViewById(R.id.grid_view);

    // Instance of ImageAdapter Class
    gridView.setAdapter(new ImageAdapter(this));

    gridView.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Intent i = new Intent(getApplicationContext(), FullImageActivity.class);
            i.putExtra("id", position);
            startActivity(i);
        }
    });
}}

and

public class ImageAdapter extends BaseAdapter {
private Context mContext;

//Images in array
public Integer[] mThumbIds = {
        R.drawable.img1, R.drawable.img2,
        R.drawable.img3, R.drawable.img4,
        R.drawable.img5, R.drawable.img6,
        R.drawable.img7, R.drawable.img8,
        R.drawable.img9, R.drawable.img10,
        R.drawable.img11, R.drawable.img12,
        R.drawable.img13, R.drawable.img14,
        R.drawable.img15, R.drawable.img16,
        R.drawable.img17, R.drawable.img18,
        R.drawable.img19
};

public ImageAdapter(Context c){
    mContext = c;
}

@Override
public int getCount() {
    return mThumbIds.length;
}

@Override
public Object getItem(int position) {
    return mThumbIds[position];
}

@Override
public long getItemId(int position) {
    return 0;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    ImageView imageView = new ImageView(mContext);
    //getResizedBitmap(mThumbIds[position], 80, 80);
    imageView.setImageResource(mThumbIds[position]);
    imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
    imageView.setLayoutParams(new GridView.LayoutParams(200, 200));
    return imageView;
}

public static Bitmap getResizedBitmap(Bitmap image, int newHeight, int newWidth) {
    int width = image.getWidth();
    int height = image.getHeight();
    float scaleWidth = ((float) newWidth) / width;
    float scaleHeight = ((float) newHeight) / height;
    // create a matrix for the manipulation
    Matrix matrix = new Matrix();
    // resize the bit map
    matrix.postScale(scaleWidth, scaleHeight);
    // recreate the new Bitmap
    Bitmap resizedBitmap = Bitmap.createBitmap(image, 0, 0, width, height,
            matrix, false);
    return resizedBitmap;
}}

Now I would load those images from an output array by a php file containing the last part of image path like url + .getString("img")

[{"img":"2015.jpg"},{"img":"to.jpg"},{"img":"its.jpg"},{"img":"eat.jpg"},
{"img":"ice.jpg"},{"img":"ata.jpg"},{"img":"ello.jpg"}]

The array is not static. Could anyone please give me ideas or suggestion about it? I know I have to parse a json array but don't know how to load it.

Any help would be appreciated.

code is here

public Bitmap getImage(String pic_string){

    String IMAGE_URL = "http://yourwebsite.com/photo/"+pic_string;

                InputStream in = new URL(IMAGE_URL).openStream();
                 bmp = BitmapFactory.decodeStream(in);
                 return bmp;

    }

if your pic reside in drawables

this function will return drawable but you must remove .png/.jpg etc from string

public Drawable getDrawable(String name) {

        int resourceId = getResources().getIdentifier(name, "drawable", getPackageName());
        return getResources().getDrawable(resourceId);
    }