Reputation: 299
I have dialog class like this
class Dialog_Open_DataPicker exten dialog {
Dialog_Open_DataPicker(Context c){}
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.dialog_date_picker);
}
}
I call that dialog like this:
Dialog_Open_DataPicker d = new Dialog_Open_DataPicker(Offer.this);
d.show();
I want to get the date from my dialog to my activity, how please? thanks in advance
Upvotes: 2
Views: 107
Reputation: 3552
Creates and shows dialog for showing date. It sets value in given textbox in you Activity class.
public static void showDate(Context context,final TextView view)
{
final Dialog dialog = new Dialog(context);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.date_dialog);
dialog.setCancelable(true);
dialog.show();
dialog.findViewById(R.id.set_time).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
DatePicker datePicker=(DatePicker)dialog.findViewById(R.id.datePicker);
int year = datePicker.getYear();
int month = datePicker.getMonth()+1;
int day = datePicker.getDayOfMonth();
StaticDateVariables.DATE_FROM_DATE_DIALOG=new StringBuilder()
.append(month).append("-").append(day).append("-")
.append(year).toString();
view.setText(StaticDateVariables.DATE_FROM_DATE_DIALOG);
dialog.dismiss();
}
});
}
Upvotes: 2