2013-10-23 64 views
0

我使用的是Android中的列表視圖和圖庫..我有3個視圖作爲列表項目,即聯繫人照片,名稱和添加該聯繫人的按鈕。當用戶單擊列表視圖中的按鈕時,該項目的聯繫人照片應該添加到圖庫中...任何人都可以請告訴如何實現此目的?如何在圖庫android中顯示列表視圖選擇的圖像?

回答

0

如果我的理解是正確的,爲什麼你不能只下載圖像並將它們保存在SD卡中?它會自動顯示在畫廊中。如果圖庫中沒有顯示,則可以在將圖像下載到SD卡後隱式調用以下內容。

sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, 
Uri.parse("file://" + Environment.getExternalStorageDirectory()))); 
0

將圖片保存到SD卡。但在此之後,您將無法在圖庫中看到該圖像。要看到這張圖片,你必須刷新使用的SD卡

broadcast(sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, 
Uri.parse("file://" + Environment.getExternalStorageDirectory().getAbsolutePath())));) 

當你要保存這張圖片。

0

@Nidhi可以添加圖像像

private void addPicToGallery() { 
    Intent media = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE); 


//mCurrentPhotoPath is the path to image. 
    File f = new File(mCurrentPhotoPath); 
    Uri contentUri = Uri.fromFile(f); 
    media.setData(contentUri); 
    this.sendBroadcast(media); 
} 
相關問題