我正在尝试从 Gallery Widget 加载选定的图像并将其加载到另一个活动中,我将非常感谢帮助!
基本上它是关于拍摄我在画廊中选择的图像并在OnItemClick
意图中制作,或者我不知道在另一个活动中查看图像。
该类如下所示:
public class Motos extends Activity implements OnClickListener, OnItemSelectedListener, OnItemClickListener{
Gallery g;
Integer[] images = {
R.drawable.image1,
R.drawable.image2,
R.drawable.image3,
R.drawable.image4 };
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.moto);
g = (Gallery) findViewById(R.id.gallery1);
g.setOnItemClickListener(this);
g.setSpacing(2);
}
public class ImageAdapter extends BaseAdapter {
public ImageAdapter(Context c) {
mContext = c;
}
public int getCount() {
return images.length;
}
public Object getItem(int position) {
return images[position];
}
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
ImageView i = new ImageView(mContext);
i.setImageResource(images[position]);
i.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
//i.setLayoutParams(new Gallery.LayoutParams(136, 88));
return i;
}
private Context mContext;
}
@Override
public void onItemClick(AdapterView parent, View v, int position, long id) {
// TODO Auto-generated method stub
}
}