图库发送位置网址并显示Android

时间:2012-11-17 10:36:04

标签: android android-intent image-gallery

我正在使用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);

0 个答案:

没有答案