2014-09-08 6 views
0

URI가있는 arrayList가 있는데 갤러리로 열려고합니다. 개봉 이미지 URI가 주식 갤러리가있는 arraylist에 있음

내가 지금 무엇을 가지고 :

public void btnChoosePhotosClick(View v){ 

    ArrayList<String> selectedItems = imageAdapter.getCheckedItems(); 
    Toast.makeText(MainActivity.this, "Total photos selected: "+selectedItems.size(), Toast.LENGTH_SHORT).show(); 
    Log.d(MainActivity.class.getSimpleName(), "Selected Items: " + selectedItems.toString()); 

    Intent intent = new Intent(); 
    intent.setAction(Intent.ACTION_VIEW); 
    intent.setDataAndType(Uri.parse("file://" + selectedItems), "image/*"); 
    startActivity(intent); 
} 

그러나 이것은 단지 문자열 대신 텍스트로 "썸네일"

GetCheckItems()

public ArrayList<String> getCheckedItems() { 
     ArrayList<String> mTempArry = new ArrayList<String>(); 

     for(int i=0;i<mList.size();i++) { 
      if(mSparseBooleanArray.get(i)) { 
       mTempArry.add(mList.get(i)); 
      } 
     } 

     return mTempArry; 
    } 

답변

1

을 빈 갤러리 열리지 않는 경우 , 우리를 찾으려고 노력하십시오

// Instead of Strings, return the Uri of each file. 
ArrayList<Uri> selectedItems = imageAdapter.getCheckedItems(); 
Uri.fromFile(file);

당신이 당신의 imageAdapter.getCheckedItems();에있는 파일 열린 우리당을 전달하는 관리하는 경우가 작동합니다 :

라는 방법이있다.

의도에서이 작업을 시도해보십시오

Intent intent = new Intent(); 
intent.setAction(Intent.ACTION_VIEW); 
intent.setType("image/*"); /* All Image Types */ 
intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, selectedItems); 
startActivity(intent); 
+0

를 내가이 오류 : 오류 : (101, 15) 오류 : 클래스 의도의 방법 putParcelableArrayListExtra 주어진 유형에 적용 할 수 없습니다; 필수 : ​​String, ArrayList found : String, ArrayList 이유 : 실제 인수 ArrayList 을 ArrayList 메서드 호출에 의한 변환 – Chimpanse

+0

파일을 가져 오는 중입니까? 파일을 전달한 다음 사용해야합니다. Uri.getFromFile (file), String 대신 모든 파일 URI를 가져오고 ArrayList selectedItems를 전달하면 제대로 작동합니다. –

+0

내가보기에 예를 볼 수있는 곳이나, 내가 혼란 스럽기 때문에 당신이하는 말을하는 법을 아십니까? – Chimpanse