I am using Date picker on one of the edittext
ID of edit text is :: android:id=\"@+id/DATE_EDIT_TEXT_ID\"
// try this
public class SearchPage extends FragmentActivity {
EditText mEdit;
DialogFragment newFragment;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.search_page);
mEdit = (EditText)findViewById(R.id.DATE_EDIT_TEXT_ID);
newFragment = new SelectDateFragment();
mEdit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
newFragment.show(getFragmentManager(), "DatePicker");
}
});
}
public void populateSetDate(int year, int month, int day) {
mEdit.setText(day+"/"+month+"/"+year);
}
public class SelectDateFragment extends DialogFragment implements DatePickerDialog.OnDateSetListener {
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final Calendar calendar = Calendar.getInstance();
int yy = calendar.get(Calendar.YEAR);
int mm = calendar.get(Calendar.MONTH);
int dd = calendar.get(Calendar.DAY_OF_MONTH);
return new DatePickerDialog(getActivity(), this, yy, mm, dd);
}
public void onDateSet(DatePicker view, int yy, int mm, int dd) {
populateSetDate(yy, dd, mm+1);
}
}
}