2017-03-10 18 views
0
protected void onActivityResult(int requestCode, int resultCode, Intent data) { 
    if (requestCode == REQUEST_CODE_PICKER 
      && resultCode == RESULT_OK && data != null) { 

     // Uri FilePath = data.getData(); 

     images = data.getParcelableArrayListExtra(ImagePickerActivity.INTENT_EXTRA_SELECTED_IMAGES); 
     StringBuilder sb = new StringBuilder(); 

     for (int i = 0; i < images.size(); i++) { 
      sb.append(images.get(i).getName() + "\n"); 
      imageFile = new File(images.get(i).getPath()); 
      fileList.add(imageFile.getAbsoluteFile()); 
      bitmap = BitmapFactory.decodeFile(fileList.get(i)+""); 

     } 

     // System.out.println("Images :" + bitmap); 

     tvtest.setText(sb.toString()); 
    } 
} 
+0

編碼?我不確定你的問題是什麼?添加一些解釋。 – Wizard

+0

我想上傳多個圖像到服務器。所以如何在遠程服務器上上傳多個圖片。 – user5653405

+0

我建議你使用amazon的s3服務器。這裏是github示例鏈接https://github.com/awslabs/aws-sdk-android-samples – Wizard

回答

1

我想你的意思是「如何在數組中包含多個圖像」。

您可以使用ArrayList來存儲你的位圖:

ArrayList<Bitmap> arrayListOfBitmaps = new ArrayList<Bitmap>(); 
for (int i = 0; i < images.size(); i++) { 
    imageFile = new File(images.get(i).getPath()); 
    bitmap = BitmapFactory.decodeFile(fileList.get(i)+""); 
    arrayListOfBitmaps.add(bitmap); // Add a bitmap 
} 

或者,如果你真的想用一個數組:

Bitmap[] bitmapArray = new Bitmap[10]; 

但請小心使用位圖。他們可以吃掉很多設備資源,這將導致OutOfMemoryError

+0

現在該如何發佈這個數組。 – user5653405

+0

@ user5653405你在網絡中使用哪個庫? – szholdiyarov