我有以下两个类这是图像适配器类:
public class ImageAdapter extends BaseAdapter {
private Context myContext;
private int[] myImageIds = { R.drawable.member, R.drawable.me,
R.drawable.member, R.drawable.me};
public ImageAdapter(Context c) {
this.myContext = c;
}
public int getCount() {
return this.myImageIds.length;
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView,
ViewGroup parent) {
ImageView iv = new ImageView(this.myContext);
iv.setImageResource(this.myImageIds[position]);
// Image should be scaled somehow
//iv.setScaleType(ImageView.ScaleType.CENTER);
//iv.setScaleType(ImageView.ScaleType.CENTER_CROP);
//iv.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
//iv.setScaleType(ImageView.ScaleType.FIT_CENTER);
//iv.setScaleType(ImageView.ScaleType.FIT_XY);
//iv.setScaleType(ImageView.ScaleType.FIT_END);
iv.setLayoutParams(new Gallery.LayoutParams(300, 300));
return iv;
}}
这是拥有画廊的班级:
public class GreekStore0 extends Activity{
Gallery myGallery;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.store);
myGallery = (Gallery) findViewById(R.id.gallery1);
myGallery.setAdapter(new ImageAdapter(this));
}}
我想要做的不是从可绘制文件夹中获取图像以从服务器获取它们。现在在开发中,我希望这台服务器成为我的本地主机。我正在使用 XAMPP 来管理与另一部分中的应用程序同步的数据库。