Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Teaching & learning

Egoitz Gonzalez aldakur

💭
Teaching & learning
View GitHub Profile
@aldakur
aldakur / LocaleHelper.java
Created Jun 20, 2016 — forked from gunhansancar/LocaleHelper.java
While developing your awesome application, sometimes you are required to add a language change feature to your app on the fly. However, Android OS does not directly support this behaviour. And therefore, you need to solve this situation in some other ways. For more details see http://gunhansancar.com/change-language-programmatically-in-android/
View LocaleHelper.java
package com.gunhansancar.android.sdk.helper;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.preference.PreferenceManager;
import java.util.Locale;
View MainApplication.java
package com.gunhansancar.android.example.application;
import android.app.Application;
import com.gunhansancar.android.sdk.helper.LocaleHelper;
/**
* When your application is launched this class is loaded before all of your activies.
* And the instance of this class will live through whole application lifecycle.
* <p/>
View TestActivity.java
package com.gunhansancar.android.example.activity;
import android.content.res.Resources;
import android.support.v7.app.AppCompatActivity;
import android.widget.TextView;
import com.gunhansancar.android.example.R;
import com.gunhansancar.android.sdk.helper.LocaleHelper;
import butterknife.Bind;