Using DatePickerDialog widget

import android.app.DatePickerDialog;
import android.widget.Toast;
import android.view.View;
import java.util.Calendar;

Calendar c=Calendar.getInstance();
int y = c.get(Calendar.YEAR);
int m = c.get(Calendar.MONTH);
int d = c.get(Calendar.DAY_OF_MONTH);
DatePickerDialog dpd = new DatePickerDialog(this,
        new DatePickerDialog.OnDateSetListener() {
            @Override            public void onDateSet(DatePicker view, int ry,
                                  int rm, int rd)  //recieving selected date            {
                String dt=rd + "-" + (rm + 1) + "-" + ry;
                Toast.makeText(getApplicationContext(),"Selected date is "+dt,Toast.LENGTH_LONG).show();
            }
        }, y, m,d); //passing current datedpd.show();



Comments

Popular posts from this blog

Creating and using IntentService

Using JSON Object with PHP

Using SQLite with Android