2012-12-19 4 views
-2

어떻게 안드로이드에 색상 선택기를 사용 하는가? 다음 코드를 시도 :안드로이드의 색상 선택 도구?

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

그래서는 색상 선택기에 와서 않는 코드 적절한 방법 – urveshpatel50

+2

을 수행하지만 어쩌면 당신은 색상을 따기위한 라이브러리를 사용할 수 있습니까? 당신은 소스 코드를 다운로드하고 좀 걸릴 수 있습니다 안드로이드에 대한 색상 선택을 할 – stealthjong

+2

표준 방법은 http://code.google.com/p/android-color-picker/입니다 ... – AurA

답변