Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As I can't find a way to do this as I mentioned before, I've reached a solution by having 2 buttons (start and end) to select the dates, instead of only havin one and use a loop. After that, i created another class, and each button calls a different class.</p> <p>Declaration of the buttons and the methods "showStartDatePicker" and "showEndDatePicker":</p> <pre><code>final Button startDate = (Button)findViewById(R.id.startDate); final Button endDate = (Button)findViewById(R.id.endDate); public void showStartDatePicker(View v) { DialogFragment newFragment = new StartDatePickerFragment(); newFragment.show(getFragmentManager(), "StartDatePicker"); } public void showEndDatePicker(View v) { DialogFragment newFragment = new EndDatePickerFragment(); newFragment.show(getFragmentManager(), "EndDatePicker"); } </code></pre> <p>Class "StartDatePickerFragment":</p> <pre><code>public class StartDatePickerFragment extends DialogFragment implements DatePickerDialog.OnDateSetListener { @Override public Dialog onCreateDialog(Bundle savedInstanceState) { // Use the current date as the default date in the picker final Calendar c = Calendar.getInstance(); int year = c.get(Calendar.YEAR); int month = c.get(Calendar.MONTH); int day = c.get(Calendar.DAY_OF_MONTH); // Create a new instance of DatePickerDialog and return it return new DatePickerDialog(getActivity(), this, year, month, day); } public void onDateSet(DatePicker view, int year, int month, int day) { // Do something with the date chosen by the user Toast.makeText(getActivity(), "Fecha seleccionada: " + day + "/" + (month+1) + "/" + year, Toast.LENGTH_SHORT).show(); } } </code></pre> <p>Class "EndDatePickerFragment":</p> <pre><code>public class EndDatePickerFragment extends DialogFragment implements DatePickerDialog.OnDateSetListener { @Override public Dialog onCreateDialog(Bundle savedInstanceState) { // Use the current date as the default date in the picker final Calendar c = Calendar.getInstance(); int year = c.get(Calendar.YEAR); int month = c.get(Calendar.MONTH); int day = c.get(Calendar.DAY_OF_MONTH); // Create a new instance of DatePickerDialog and return it return new DatePickerDialog(getActivity(), this, year, month, day); } public void onDateSet(DatePicker view, int year, int month, int day) { LineGraph lineGraph = new LineGraph(); lineGraph.run(getActivity()); } } </code></pre> <p>I'm almost doing the same thing twice (creating the DatePicker), but I can't find a more efficient way.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload