How to display date picker for android with only month and year fields?
infor from: http://www.codeproject.com/Questions/438056/How-to-get-a-calender-in-edit-text
et1.setOnClickListener(new View.OnClickListener() { // @Override public void onClick(View v) { final Calendar c = Calendar.getInstance(); int y = c.get(Calendar.YEAR)+4; int m = c.get(Calendar.MONTH)-2; int d = c.get(Calendar.DAY_OF_MONTH); final String[] MONTH = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; DatePickerDialog dp = new DatePickerDialog(MainActivity.this, new DatePickerDialog.OnDateSetListener() { @Override public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) { String erg = ""; erg = String.valueOf(dayOfMonth); erg += "." + String.valueOf(monthOfYear + 1); erg += "." + year; ((TextView) et1).setText(erg); } }, y, m, d); dp.setTitle("Calender"); dp.setMessage("Select Your Graduation date Please?"); dp.show(); } });
沒有留言:
張貼留言