我正在尝试在我的自定义启动器上安装图标包,我已阅读此说明 How to install icon pack但我无法理解如何使用该类,这就是我所做的:
IconPackManager ic = new IconPackManager();
HashMap<String, IconPackManager.IconPack> map = new HashMap<String, IconPackManager.IconPack>(ic.getAvailableIconPacks(false));
Iterator it = map.entrySet().iterator();
Drawable d = null;
String packName = null;
IconPackManager.IconPack packIcon = null;
while (it.hasNext()) {
Map.Entry pair = (Map.Entry)it.next();
packName = (String)pair.getKey();
packIcon = (IconPackManager.IconPack)pair.getValue();
d = packIcon.getDrawableIconForPackage(packName, iconDrawable);
setIcon(d);
}
最佳答案
解决了这个问题:
String packName = null;
IconPackManager.IconPack packIcon = null;
IconPackManager ic = new IconPackManager();
HashMap<String, IconPackManager.IconPack> map = ic.getAvailableIconPacks(true);
Iterator it = map.entrySet().iterator();
while (it.hasNext()) {
Map.Entry pair = (Map.Entry)it.next();
packName = (String)pair.getKey(); //Get icon pack name (app package)
packIcon = (IconPackManager.IconPack)pair.getValue(); //Get icons
if(packIcon.getDrawableIconForPackage("YourTargetPackageName", yourStandardIcon) != null) {
//Your own method for set icon
setIcon(packIcon.getDrawableIconForPackage("YourTargetPackageName", yourStandardIcon));
}else{
//Your own method for set icon
setIcon(yourStandardIcon);
}
}
关于java - 如何在自定义启动器上安装图标包?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42751915/