-2
如何使用顏色選擇器在android系統?我嘗試了以下代碼:顏色選擇器在android?
public class FontManager
{
// This function enumerates all fonts on Android system and returns the HashMap with the font
// absolute file name as key, and the font literal name (embedded into the font) as value.
static public HashMap< String, String > enumerateFonts()
{
String[] fontdirs = { "/system/fonts", "/system/font", "/data/fonts" };
HashMap< String, String > fonts = new HashMap< String, String >();
TTFAnalyzer analyzer = new TTFAnalyzer();
for (String fontdir : fontdirs)
{
File dir = new File(fontdir);
if (!dir.exists())
continue;
File[] files = dir.listFiles();
if (files == null)
continue;
for (File file : files)
{
String fontname = analyzer.getTtfFontName(file.getAbsolutePath());
if (fontname != null)
fonts.put(file.getAbsolutePath(), fontname);
}
}
return fonts.isEmpty() ? null : fonts;
}
}
此代碼獲取運行時錯誤。給一些樣品。
做那麼,這是否顏色選擇器來代碼有道 – urveshpatel50
? – stealthjong
,使顏色選擇器爲Android的標準方法是http://code.google.com/p/android-color-picker/ 您可以下載源代碼,並看看... – AurA