我正在使用intent将选定的图像从图库发送到NextImage.java活动。我想将图像的选定位置和图像阵列发送到下一个活动。我对意图部分感到困惑,有人可以帮忙吗
将点击的项目和网址发送到nextImage活动的代码。
public void showGallery(){
String[]imageUrls= new String[PostDetails.size()];
for (int index=0;index<imageUrls.length;index++){
imageUrls[index]=PostDetails.get(index).getImag();
}
options = new DisplayImageOptions.Builder()
.showStubImage(R.drawable.stub_image)
.displayer(new RoundedBitmapDisplayer(3))
.cacheInMemory()
.cacheOnDisc()
.build();
gallery = (Gallery) findViewById(R.id.img_gallery);
gallery.setAdapter(new ImagePagerAdapter(imageUrls));
gallery.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> gallery, View view, int position, long id) {
Intent galleryIntent = new Intent(ImageGalleryActivity.this, MyNextImage.class);
galleryIntent.putExtra(imageUrls, position);
startActivity(galleryIntent);
}
}
我的下一个图像类如下。
公共类NextImage扩展BaseActivity实现OnClickListener {
private ViewPager pager;
String[] imageUrls;
private DisplayImageOptions options;
String images;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.view_flipper_item);
Bundle bundle = getIntent().getExtras();
String[] imageUrls = bundle.getStringArray(images);
int pagerPosition = bundle.getInt(position, 0);