2015-11-30 47 views
0

我正在製作一個從數據庫獲取數據的應用程序,它應該使用ImageIcon。如何在Android中使用該類並將其轉換爲Drawable以在應用中顯示它?Android將ImageIcon轉換爲Drawable

這不是來自資源文件。它來自ImageIcon,作爲我從數據庫接收的對象的變量。

+0

看到這個答案 - http://stackoverflow.com/questions/16320725/how-do-i-convert-an-imageicon-to-bitmapdrawable-in-android – Zain

+1

可能的複製[如何從資源創建Drawable](http://stackoverflow.com/questions/4818118/how-to-create-drawable-from-resource) – abbath

回答

0

試試這個

Bitmap bitmap = BitmapFactory.decodeFile("/path/images/image.png"); 
Drawable d = new BitmapDrawable(getResources(), bitmap); 
相關問題