2011-06-08 52 views
0

我不能properManner得到圖標,我用PackageManager圖標問題的android

代碼示例

::List<PackageInfo> applications = getPackageManager().getInstalledPackages(0); 
     for(PackageInfo info : applications){ 
      Drawable icon = info.applicationInfo.loadIcon(getBaseContext()); 
      } 

如果我print圖標logcat的然後我得到結果「圖標是[email protected]
在main.xml文件:<ImageView android:id="@+id/imageView1" android:layout_height="wrap_content" android:layout_width="wrap_content" android:src="@drawable/icon"></ImageView>

我只想顯示圖標,ImageView的。

+0

如果youar得到的結果在日誌中貓有什麼問題呢? – ingsaurabh 2011-06-08 09:25:57

+0

如何將其顯示給模擬器? – 2011-06-08 09:27:33

+1

位圖位圖=((BitmapDrawable)icon).getBitmap(); imageView.setImageBitmap(位圖);這是你需要的嗎? – ingsaurabh 2011-06-08 09:30:13

回答

2

爲了從繪製並顯示在圖像視圖fecth位嘗試下面的代碼

Bitmap bitmap = ((BitmapDrawable)icon).getBitmap(); 
imageView.setImageBitmap(bitmap);