Catch show and change Time / Date

-1

Good morning! I would like to take the time of the mobile to play on the screen for the user to be able to change and save the time the user chooses and the same thing for the date. example look similar to the alarm clock

    
asked by anonymous 28.03.2014 / 15:24

1 answer

2

I solved my problem with this code!

private OnDateSetListener mDataSetListener = new OnDateSetListener(){

    @Override
    public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth){
        int a = year;
        int m = monthOfYear;
        int d = dayOfMonth;
        if (m >= 1 && m<10){
            mm = "0"+String.valueOf(m);
        }else
            mm = String.valueOf(m);
        if (d>=1 && d<10){
            dd = "0" + String.valueOf(d);
        }else
            dd = String.valueOf(d);

        data = String.valueOf(ano) + "-" +mm+ "-" +dd;
        mostrarData();
    }
};

private void mostrarData(){
    Toast.makeText(this, "Data Selecionada" + data,Toast.LENGTH_LONG).show();
}    public void onClickData(View v){
    final DatePickerDialog dialogo = new DatePickerDialog(this, mDataSetListener, ano, mes, dia);
    dialogo.show();
}
    
30.03.2014 / 15:47