/**
* 作者:王東一 on 2015/7/13 14:46
*/
public class MyDatePickerDialog extends DatePickerDialog {
public MyDatePickerDialog(Context context, OnDateSetListener callBack, int year, int monthOfYear, int dayOfMonth) {
super(context, callBack, year, monthOfYear, dayOfMonth);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
}
}
使用方式 MyDatePickerDialog picker = new MyDatePickerDialog (MainActivity. this , DatePickerListener,
iYear, iMonth, iDay); picker.setCancelable( true ); picker.setCanceledOnTouchOutside( true ); picker.setButton(DialogInterface.BUTTON_POSITIVE, "OK" , new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Log.d( "Picker" , "Correct behavior!" ); } }); picker.setButton(DialogInterface.BUTTON_NEGATIVE, "Cancel" , new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Log.d( "Picker" , "Cancel!" ); } }); picker.show();