我有這個imageview
對我的佈局:爲什麼這ImageView不顯示我的圖像?
<ImageView
android:id="@+id/profileImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@id/profileImageLabel"
android:layout_alignParentRight="true"
android:maxWidth="90px"
android:maxHeight="90px"/>
,我給它的圖像源動態上的onCreate():
Bitmap bm = BitmapFactory.decodeFile("c:/logo.png");
profileImage.setImageBitmap(bm);
profileImage.invalidate();
但是當我測試的應用程序,它不不顯示圖像,只顯示黑屏。
爲什麼imageview
不能顯示,只有黑屏?
以及如果我需要從手機中獲取文件會發生什麼? (我需要這個到我的應用程序,因爲用戶可以從他們的手機中選擇一個圖像並用作配置文件圖像) – NullPointerException
那麼你可以按照你所做的方式,只需輸入正確的文件路徑。你可以在這裏閱讀更多關於這個:http://developer.android.com/guide/topics/data/data-storage.html#filesExternal – Durza007