2012-11-17 63 views
0

我正在使用意向從圖像庫發送到NextImage.java活動的選定圖像。我想將圖像的選定位置和圖像數組發送到下一個活動。我正在混淆意圖。意圖庫圖像android位置和arraylist

String[]imageUrls= new String[PostDetails.size()]; 

for (int index=0;index<imageUrls.length;index++){ 

     imageUrls[index]=PostDetails.get(index).getImag(); 
} 



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); 

     } 
在接下來的圖像類

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

你把額外如下:

galleryIntent.putExtra("IMAGE_URLS", imageUrls); 
galleryIntent.putExtra("POSITION", position); 

,並獲得額外回如下:

String[] imageUrls = bundle.getStringArray("IMAGE_URLS"); 
int pagerPosition = bundle.getInt("POSITION", 0);