I am using Eclipse to build an Android Application, I have one Activity which has 2 EditTexts and when I click on them, they will redirect me to the other activity which I will then select a date from CalendarView and time from TimePicker. Afterwards, I will click on Done and it will redirect me back to the previous Activity with the EditText filled.
Now, my question is, how do I populate the EditText with the date and time selected from the CalendarView and TimePicker in dd/MMM/yyyy and 24hr format?? I tried using Intent but I don't know how to code in.
Here's my partial code:
public class RentStartActivity extends Activity {
CalendarView calendar1;
TimePicker time1;
Button btnCancel1, btnDone1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_rent_start);
btnCancel1 = (Button) findViewById(R.id.btnCancel1);
btnCancel1.setOnClickListener(new OnClickListener(){
public void onClick(View v){
Intent cancel = new Intent(RentStartActivity.this, SearchActivity.class);
startActivity(cancel);
}
});
btnDone1 = (Button) findViewById(R.id.btnDone1);
btnDone1.setOnClickListener(new OnClickListener(){
public void onClick(View v){
Intent done = new Intent(RentStartActivity.this, SearchActivity.class);
done.putExtra("Date1", calendar1.getDate());
done.putExtra("Time", time1.getDrawingTime());
startActivity(done);
}
});
}