I used View Calendar Spanish but I am not sure how to change the language, there is some property that is not available anywhere.
Now I have this:
<CalendarView
android:id="@+id/calendari"
android:layout_margin="10dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weekNumberColor="@color/botoCalendari"
android:focusedMonthDateColor="#d91f1f"
android:weekSeparatorLineColor="#1fd928"
android:selectedWeekBackgroundColor="#1fd9d6"
android:unfocusedMonthDateColor="#d91fd9"
/>
Is there any property or by code ?
Thank you very much.
This may helps you.
import android.app.Activity;
import android.content.res.Configuration;
import android.os.Bundle;
public class Main extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String languageToLoad = "fa"; // your language
Locale locale = new Locale(languageToLoad);
Locale.setDefault(locale);
Configuration config = new Configuration();
config.locale = locale;
getBaseContext().getResources().updateConfiguration(config,
getBaseContext().getResources().getDisplayMetrics());
this.setContentView(R.layout.main);
}
}
you find example here
Nope. CalendarView doesn't have such a property. The language used in the view is the default device's language.
You can try to change the locale dynamically when starting your application.
Example:
Locale locale = new Locale("en_US");
Locale.setDefault(locale);
Configuration config = new Configuration();
config.locale = locale;
context.getApplicationContext().getResources().updateConfiguration(config, null);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With