I'm trying to input date values from an editText, but i keep making error, what i should do?
EditText DataI = (EditText) findViewById(R.id.DataI);
EditText DataF = (EditText) findViewById(R.id.DataF);
calendar1.setTime(DataI);
calendar2.setTime(DataF);
use:
SimpleDateFormat format=new SimpleDateFormat("dd/MM/yyyy");
calendar1.setTime(format.parse(DataI.getText().toString());
calendar2.setTime(format.parse(DataF.getText().toString());
There are components in Android API that're created for date-time input:
I think it's more appropriate to use the than an EditText
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.