我尝试在自定义启动器上安装图标包,我已阅读此说明How to install icon pack,但我无法理解如何使用该课程,此处&#39我做了什么:
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);
}
答案 0 :(得分:7)
解决了这个问题:
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);
}
}
答案 1 :(得分:2)
仅当安装了以下任何软件包时才能使用
1)是否已安装?
org.adw.launcher.THEMES
com.gau.go.launcherex.theme
getAvailableIconPacks应返回HashMap大小&gt; 0
2)下面是否返回有效drawable或null?
d = packIcon.getDrawableIconForPackage(packName, iconDrawable);
在你的情况下使用是错误的。
您正在迭代抛出图标提供程序包名称。在以下情况下,您要求
d = packIcon.getDrawableIconForPackage(packName, iconDrawable);
//means
//d = packIcon.getDrawableIconForPackage("org.adw.launcher.THEMES",conDrawable)
因此,如果没有google play的上述主题安装,则仅返回默认的drawable。