2012-01-16 7 views
2

아랍어로 응용 프로그램을 개발했으며 와일드 한 Android 기기를 지원하고 싶습니다. 아랍어로 장치를로드하거나 영어로로드하려면 장치에서 아랍어를 지원하는지 감지하고 싶습니다.Android 언어 지원 확인

답변

1

의 목록을 얻을 수 있습니다.

사용자 로캘에 따라 적절한 언어 리소스를 표시하려는 경우 프레임 워크에서 쉽게 허용합니다. string.xml 파일을 this d.android.com 문서에 설명 된대로 적절한 리소스 폴더에 추가하면 OS에서 해당 파일을 사용합니다.

0

사용 getAvailableLocales()는 사용 가능한 언어

그냥 체크 당신이 <context>.getResources().getConfiguration().locale를 사용할 수있는 구성 로케일 (A java.util.Locale이다)에 필요한 경우
0

당신은 아랍어 단어로 हिन्दी 대체 특정 언어 지원을

if (isSupported(baseContext, "हिन्दी")) 
    languageList.add("हिन्दी") 

를 확인하려면이 방법을 사용할 수 있습니다

public static boolean isSupported(Context context, String text) { 
     int w = 200, h = 80; 

     Resources resources = context.getResources(); 
     float scale = resources.getDisplayMetrics().density; 
     Bitmap.Config conf = Bitmap.Config.ARGB_8888; 
     Bitmap bitmap = Bitmap.createBitmap(w, h, conf); // this creates a MUTABLE bitmap 
     Bitmap orig = bitmap.copy(conf, false); 
     Canvas canvas = new Canvas(bitmap); 
     Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); 
     paint.setColor(Color.rgb(0, 0, 0)); 
     paint.setTextSize((int) (14 * scale)); 

     // draw text to the Canvas center 
     Rect bounds = new Rect(); 
     paint.getTextBounds(text, 0, text.length(), bounds); 
     int x = (bitmap.getWidth() - bounds.width())/2; 
     int y = (bitmap.getHeight() + bounds.height())/2; 

     canvas.drawText(text, x, y, paint); 
     boolean res = !orig.sameAs(bitmap); 
     orig.recycle(); 
     bitmap.recycle(); 
     return res; 
} 

Refer full