Create CustomDatePickerDialog with Below code
public class CustomDatePickerDialog extends DatePickerDialog
{
public CustomDatePickerDialog(Context context, OnDateSetListener callBack, int year, int monthOfYear, int dayOfMonth,View attachedView)
{
super(context, callBack, year, monthOfYear, dayOfMonth);
getDatePicker().setTag(attachedView.getId());
}
public CustomDatePickerDialog(Context context, OnDateSetListener callBack, int year, int monthOfYear, int dayOfMonth)
{
super(context, callBack, year, monthOfYear, dayOfMonth);
}
public CustomDatePickerDialog(Context context, int theme, OnDateSetListener listener, int year, int monthOfYear, int dayOfMonth)
{
super(context, theme, listener, year, monthOfYear, dayOfMonth);
}
}
Call it like below
btnSelectDate.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View view)
{
CustomDatePickerDialog customDatePickerDialog = new CustomDatePickerDialog(MainActivity.class,dateSetListener,2014,10,1,view);
customDatePickerDialog.show();
}
});
You will get which button invoked dialog like below in listener
DatePickerDialog.OnDateSetListener dateSetListener = new DatePickerDialog.OnDateSetListener()
{
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth)
{
int viewID = view.getTag();
switch(viewID)
{
case R.id.btnDatePicker1;
{
//DO Something
}
case R.id.btnDatePicker2;
{
//DO Something
}
}
}
};
Note : API Level 11 Required for getDatePicker() call in custom dialog