2012-10-17 19 views
0

我有下面的代碼讓我的Android設備上的目錄我的JPG文件:如何從Android的ImageView中的緩存目錄中放置文件?

File f = new File(cacheDir, fn); 

如何採取f,並把它放在一個ImageView的?

ImageView imgView = (ImageView)header.findViewById(R.id.imvCover); 

// what call do I make here? 
// this obviously is not correct and just for example. 
imgView.setToFile(f); 

回答

1

試試這個。 既然你有一個文件對象使用下面的代碼。

這可能會幫助你

Bitmap bmp = BitmapFactory.decodeFile(f.getAbsolutePath()); 
imgView.setImageBitmap(bmp); 
0

我認爲這是正確的,不是嗎?

Bitmap b = decodeFile(f); 
imgView.setImageBitmap(b); 
+0

didnt它得到解決? –

+0

'fn'是什麼? @ethan艾倫 –

相關問題