我试图将Caldroid
库放在另一种语言中但不能。
这是我的代码:
public void setLocale() {
Locale locale = new Locale("ca", "ES");
Locale.setDefault(locale);
Configuration config = new Configuration();
config.locale = locale;
getBaseContext().getResources().updateConfiguration(config, getBaseContext().getResources().getDisplayMetrics());
}
答案 0 :(得分:1)
The code of the calendar:
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
setLocale()
View rootView = inflater.inflate(R.layout.calendar, container, false);
LinearLayoutParent = (LinearLayout) rootView.findViewById(R.id.linear_vertical_calendar);
caldroidFragment = new CaldroidSampleCustomFragment();
if (savedInstanceState == null) {
Bundle args = new Bundle();
cal = Calendar.getInstance();
args.putInt(CaldroidFragment.MONTH, cal.get(Calendar.MONTH) + 1);
args.putInt(CaldroidFragment.YEAR, cal.get(Calendar.YEAR));
caldroidFragment.setArguments(args);
}
FragmentManager fragManager = getActivity().getSupportFragmentManager();
FragmentTransaction t = fragManager.beginTransaction();
t.replace(R.id.calendar1, caldroidFragment);
t.commit();
final CaldroidListener listener = new CaldroidListener() {
@Override
public void onSelectDate(Date date, View view) {
// Do something
}
@Override
public void onCaldroidViewCreated() {
// Supply your own adapter to weekdayGridView (SUN, MON, etc)
TextView txtMonths = caldroidFragment.getMonthTitleTextView();
Typeface myTypeface = Typeface.createFromAsset(getActivity().getAssets(), "fonts/Roboto-Light.ttf");
txtMonths.setTypeface(myTypeface);
}
};
caldroidFragment.setCaldroidListener(listener);
return rootView;
}
public void setLocale() {
enter code hereLocale locale = new Locale("ca","ES");
Locale.setDefault(locale);
Configuration config = new Configuration();
config.locale = locale;
getBaseContext().getResources().updateConfiguration(config,
getBaseContext().getResources().getDisplayMetrics());
}