[RESOLVIDO] Como setar o texto dos botões de um DatePickerDialog para PT-BR

Pessoal, estou numa aplicação onde preciso usar uma DatePickerDialog.

Estava seguindo o exemplo do site oficial do android mesmo: http://developer.android.com/resources/tutorials/views/hello-datepicker.html

Mas este, por padrão vem no formato americano, e os botões estão em ingles(“set” e “cancel”).

Não vejo como mudar o formato e o texto dos botões. Quem souber e puder dar uma ajuda, eu agradeço…

Segue o codigo.

private TextView mDateDisplay;
private Button mPickDate;
private int mYear;
private int mMonth;
private int mDay;

static final int DATE_DIALOG_ID = 0;

protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

    // capture our View elements
    mDateDisplay = (TextView) findViewById(R.id.dateDisplay);
    mPickDate = (Button) findViewById(R.id.pickDate);

    // add a click listener to the button
    mPickDate.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            showDialog(DATE_DIALOG_ID);
        }
    });

    // get the current date
    final Calendar c = Calendar.getInstance();
    mYear = c.get(Calendar.YEAR);
    mMonth = c.get(Calendar.MONTH);
    mDay = c.get(Calendar.DAY_OF_MONTH);

    // display the current date (this method is below)
    updateDisplay();
}

// updates the date in the TextView
private void updateDisplay() {
mDateDisplay.setText(
new StringBuilder()
// Month is 0 based so add 1
.append(mMonth + 1).append("-")
.append(mDay).append("-")
.append(mYear).append(" "));
}

// the callback received when the user "sets" the date in the dialog
private DatePickerDialog.OnDateSetListener mDateSetListener =
        new DatePickerDialog.OnDateSetListener() {

            public void onDateSet(DatePicker view, int year, 
                                  int monthOfYear, int dayOfMonth) {
                mYear = year;
                mMonth = monthOfYear;
                mDay = dayOfMonth;
                updateDisplay();
            }
        };

@Override
protected Dialog onCreateDialog(int id) {
switch (id) {
case DATE_DIALOG_ID:
return new DatePickerDialog(this,
mDateSetListener,
mYear, mMonth, mDay);
}
return null;
}

Também tive esta dúvida a muito tempo a atrás e pelo o que me disseram não tem como. Você teria que criar o componente! :frowning:

Mas espero que seja mentira isto.

[quote=felipebonezi]Também tive esta dúvida a muito tempo a atrás e pelo o que me disseram não tem como. Você teria que criar o componente! :frowning:

Mas espero que seja mentira isto.[/quote]

esperamos…

mas valew mesmo assim.

UP

Eai pessoal? não tem como mesmo?

RESOLVIDO.

Galera, este datePicker pega a linguagem padrão do celular. O que eu estava testando estava em ingles. Testei em outro que estava em portugues e funcionou perfeitamente.

Bom saber carinha! :slight_smile:

Valeu pelo feedback.

Mesmo com um dispositivo que tenha linguagem inglês você pode alterar, basta setar o Locale para Pt-br. Pelo menos no emulador funciona.

Cara nao achei esta propriedade Locale nao.