Android : Get Selected Date from dialog- Timessquare library

on Tuesday, July 29, 2014


I am new to android app development. I am using timessquare library to show datepicker. i am not able to get the selected date set in my edittext from the dialog.


where should i put et1.setText(sel_date);



public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.avail_layout);


final Calendar nextYear = Calendar.getInstance();
nextYear.add(Calendar.YEAR, 1);

final Calendar lastYear = Calendar.getInstance();
lastYear.add(Calendar.YEAR, -1);



et1 = (EditText) findViewById(R.id.date);

et1.setOnClickListener(new OnClickListener() {
@Override public void onClick(View view) {
dialogView = (CalendarPickerView) getLayoutInflater().inflate(R.layout.dialog, null, false);
dialogView.init(lastYear.getTime(), nextYear.getTime()) //
.withSelectedDate(new Date());
theDialog =
new AlertDialog.Builder(avail_activity.this).setTitle("Select a Date")
.setView(dialogView)
.setNeutralButton("Done", new DialogInterface.OnClickListener() {
@Override public void onClick(DialogInterface dialogInterface, int i) {

dialogInterface.dismiss();


}
})
.create();
theDialog.setOnShowListener(new DialogInterface.OnShowListener() {
@Override
public void onShow(DialogInterface dialogInterface) {
Log.d(TAG, "onShow: fix the dimens!");
dialogView.fixDialogDimens();
}
});
theDialog.show();

}

}

);

0 comments:

Post a Comment