在DatePicker中替换月份名称?

时间:2018-05-27 19:10:32

标签: android datepicker

我需要在日期选择器中将AD月份的名称替换为波斯月份名称,该怎么做?

public static final String[] MONTHS = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};

public static final String[] JALALI_MONTHS = {"Farvardin", "Ordibehesht","Khordad","Tir","Mordad","Shahrivar","Meher","Aban","Azar","Dey","Bahman","Esfand"};

1 个答案:

答案 0 :(得分:0)

我建议您使用String resources来执行此操作

resources>
    <string-array name="months_array">
        <item>Farvardin</item>
        <item>Ordibehesht</item>
        <item>Khordad</item>
        <item>Tir</item>
        <item>Mordad</item>
        <item>Shahrivar</item>
        <item>Meher</item>
        <item>Aban</item>
        <item>Azar</item>
        <item>Dey</item>
        <item>Bahman</item>
        <item>Esfand</item>
    </string-array>
</resources>

然后,如果您希望将其作为多语言创建一个名为strings.xml的新values-fa然后放入此strings.xml,那么它应该是这样的:

res/
    values/
        strings.xml
     values-fa/
        strings.xml

但是如果你想改变DatePicker语言,你应该做@Igor K这样的回答,也许有帮助:)