0
我想要使用以下代碼獲取已安裝應用程序圖標的列表,但它只顯示可繪製路徑的列表,但不顯示圖標(即android.graphics.drawable.BitmapDrawable @ 417530c8),如何獲取已安裝應用程序圖標的列表
有人可以告訴我我做錯了什麼。
由於
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ListView appList = (ListView) findViewById(R.id.appList);
ArrayList<Drawable> cacheArrayList = new ArrayList<Drawable>();
ArrayAdapter<Drawable> aa = new ArrayAdapter<Drawable>(this,
android.R.layout.simple_list_item_1, cacheArrayList);
appList.setAdapter(aa);
PackageManager pm = getPackageManager();
List<ApplicationInfo> packages = pm
.getInstalledApplications(PackageManager.GET_META_DATA);
for (ApplicationInfo packageInfo : packages) {
// cacheArrayList.add((String) packageInfo.loadLabel(pm));
cacheArrayList.add(packageInfo.loadIcon(pm));
}
}
}