android中的颜色选择器?

时间:2012-12-19 10:40:30

标签: java android color-picker

如何在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;
}
}

此代码出现运行时错误。提供一些样品。

1 个答案:

答案 0 :(得分:1)

我的代码中没有看到关于颜色选择器的任何内容?但也许您可以使用库来选择颜色:android-color-picker