I am using a datepicker and when i select the date from it, i want to set it in the Editext named Eprevd and for doing it I have made a inner Class (Static) named PickerDialog.java
But not getting the proper way to do it. and also getting error in this statement
pickerDialog.show(getFragmentManager(), "DatePicker");
Error is -- cannot resolve method show(android.app.fragmentmanager ,java.lang.string)
here Is the code of UpdateActivity.java
public class UpdateActivity extends AppCompatActivity {
int year_x, month_x, day_x;
private static EditText Eprevd;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_update);
Eprevd = (EditText)findViewById(R.id.Eupdateprevd);
}
public void setDateP(View view)
{
PickerDialog pickerDialog = new PickerDialog();
//but this line below is giving error..
pickerDialog.show(getFragmentManager(), "DatePicker"); // this line
}
/////////////////////////////////////////
public static class PickerDialog extends DialogFragment
implements DatePickerDialog.OnDateSetListener
{
int year_x, month_x, day_x;
@Override
public Dialog onCreateDialog(Bundle savedInstanceState)
{
Calendar cal = Calendar.getInstance();
year_x=cal.get(Calendar.YEAR);
month_x=cal.get(Calendar.MONTH);
day_x=cal.get(Calendar.DAY_OF_MONTH);
DatePickerDialog dialog;
dialog = new DatePickerDialog(getActivity(),this,year_x,month_x,day_x);
return dialog;
}
public void onDateSet(DatePicker view, int year, int month, int dayOfMonth)
{
year_x = year;
month_x = month + 1;
day_x = dayOfMonth;
Eprevd.setText(day_x + " / " + month_x + " / " + year_x);
}
}
}
Now, what should i do to counter that error..? Thanks in advance..!