すべての画像は描画可能なフォルダーに保存されます。いくつかの画像を含むギャラリー ビューを表示したい。
必要な画像の名前は文字列配列にあります。
これらの画像を表示するギャラリー ビューを取得できますか。
以下のコードを見つけました。ここでは、画像は整数です。
文字列配列を使用できますか?
public class ImageAdapter extends BaseAdapter {
private Context context;
public ImageAdapter(Context context){
this.context = context;
}
public int getCount() {
return pics.length;
}
public Object getItem(int arg0) {
return null;
}
public long getItemId(int position) {
return 0;
}
public View getView(int arg0, View arg1, ViewGroup arg2) {
ImageView iv = new ImageView(context);
iv.setImageResource(pics);
iv.setScaleType(ImageView.ScaleType.FIT_XY);
iv.setLayoutParams(new Gallery.LayoutParams(150,120));
iv.setBackgroundResource(imageBackground);
return iv;
}
}