Note that there are some explanatory texts on larger screens.

plurals
  1. POShow DatePicker with other calendar system
    text
    copied!<p>I have a <strong>Datepicker in a custom Dialog</strong> which shows the date and the user can select the date and I get the user selected date. Now I want to go further by showing other calendar </p> <p>for e.g. <strong>Persian calendar date instead of the Gregorian calender date</strong>. Now in my app when the user selects the date from the datepicker I can return the Persian date in the log. but I don't know how to change the DatePicker to show perisan date.please help.</p> <pre><code> @Override public boolean onCreateOptionsMenu(Menu menu) { menu.add("Add Detail").setIcon(R.drawable.ic_compose).setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { final Dialog dialog = new Dialog(this); dialog.setContentView(R.layout.custom); final EditText amount = (EditText) dialog.findViewById(R.id.amtEditText); final DatePicker datePicker = (DatePicker) dialog.findViewById(R.id.datePicker1); Button cancelButton = (Button) dialog.findViewById(R.id.canelButton); Button OKButton = (Button) dialog.findViewById(R.id.OKbutton); OKButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Log.d("---------------", datePicker.getDayOfMonth() +" " + datePicker.getMonth() + " " + datePicker.getYear() + " " + amount.getText()); Toast.makeText(MainActivity.this, "Got click: " + datePicker.getDayOfMonth() + " " + datePicker.getMonth() + " " + datePicker.getYear(), Toast.LENGTH_SHORT).show(); CivilDate civil = new CivilDate(datePicker.getYear(), datePicker.getMonth(), datePicker.getDayOfMonth()); PersianDate perDate = DateConverter.civilToPersian(civil); Log.d("-------", perDate.getDayOfMonth()+ " " + (perDate.getMonth() + 1) + " " + perDate.getYear() + " " + perDate.getMonthName()); datePicker.init(perDate.getYear(), (perDate.getMonth() + 1), perDate.getDayOfMonth(), null); } }); </code></pre>
 

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