Thursday, August 21, 2014

Android support multiple languages

How to support application multiple language in Android
This post about how to make your application support multiple language

Create different support languages  folder in resource  ex: values-ar,values-en



Screen Shot


Before Set Language

After Set language
Source Code

this is code for set local language

    Locale locale = new Locale("ar");
    Locale.setDefault(locale);
    Configuration config = new Configuration();
    config.locale = locale;
    getResources().updateConfiguration(config,
    getResources().getDisplayMetrics());





Full Activity Source Code



package com.example.supportmultiplelanguge;

import java.util.Locale;

import android.app.Activity;

import android.content.res.Configuration;

import android.os.Bundle;

import android.view.View;

import android.view.View.OnClickListener;

import android.widget.Button;

//@VIJAYAKUMAR

public class MainActivity extends Activity {

Button arabic_btn;

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

arabic_btn = (Button)findViewById(R.id.arabic_btn);

arabic_btn.setOnClickListener(new OnClickListener() {

@Override

public void onClick(View v) {

Locale locale = new Locale("ar");

Locale.setDefault(locale);

    Configuration config = new Configuration();

    config.locale = locale;

    getResources().updateConfiguration(config,

    getResources().getDisplayMetrics());

    setContentView(R.layout.activity_main);

}

});

}

}



Refer Here Googel Support Language




















No comments:

Post a Comment

Check out this may be help you

Related Posts Plugin for WordPress, Blogger...