0

In android studio I have added a Date Picker to my xml. My goal is to use the datepicker so that when a day on the calendar is selected(clicked) by the user, then a new Intent will start and with that intent, information will be displayed based on the intent. Of course i know how to send information and start and intent etc.

My main issue is having an onclicklistener for the individual days, and getting the actual day clicked into a variable to send. I have seen DatePickerDialog but am confused the difference between that and my DatePicker, and as to how to extract the info

enter image description here enter image description here

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115

1 Answers1

0
public class MainActivity extends AppCompatActivity implements DatePickerDialog.OnDateSetListener{

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}

@Override
public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) {
 //start your intent here with these values of year,month,dayofMonth
}

public void ShowPicker(View view) {
    DatePickerDialog datePickerDialog = new DatePickerDialog(
            this, MainActivity.this, 2016, 12, 01);
    datePickerDialog.show();
}
}

Here ShowPicker method is set to onClick event of a button. I hope got the idea. If this is not what you wanted then just explain me more I will surely help you.

Zankrut Parmar
  • 1,872
  • 1
  • 13
  • 28