Android getting current calendarview's year, month










0














In calendarview, at first I can set date but I cannot get which month and year when I click two buttons that change calendar to previous month or next month.
And even more, calendarview supports swipe to go previous or next month,
but I cannot get year and month info of now displaying calendar.
How can I get year and month info of seeing (now displaying) calendar??



enter image description here



enter image description here










share|improve this question




























    0














    In calendarview, at first I can set date but I cannot get which month and year when I click two buttons that change calendar to previous month or next month.
    And even more, calendarview supports swipe to go previous or next month,
    but I cannot get year and month info of now displaying calendar.
    How can I get year and month info of seeing (now displaying) calendar??



    enter image description here



    enter image description here










    share|improve this question


























      0












      0








      0







      In calendarview, at first I can set date but I cannot get which month and year when I click two buttons that change calendar to previous month or next month.
      And even more, calendarview supports swipe to go previous or next month,
      but I cannot get year and month info of now displaying calendar.
      How can I get year and month info of seeing (now displaying) calendar??



      enter image description here



      enter image description here










      share|improve this question















      In calendarview, at first I can set date but I cannot get which month and year when I click two buttons that change calendar to previous month or next month.
      And even more, calendarview supports swipe to go previous or next month,
      but I cannot get year and month info of now displaying calendar.
      How can I get year and month info of seeing (now displaying) calendar??



      enter image description here



      enter image description here







      android calendar calendarview






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 12 '18 at 20:40

























      asked Nov 12 '18 at 19:58









      CLANG

      13




      13






















          1 Answer
          1






          active

          oldest

          votes


















          0














           final DatePickerDialog.OnDateSetListener dateto = new DatePickerDialog.OnDateSetListener() 

          @Override
          public void onDateSet(DatePicker view, int year, int monthOfYear,
          int dayOfMonth)
          // TODO Auto-generated method stub
          myCalendar.set(Calendar.YEAR, year);
          myCalendar.set(Calendar.MONTH, monthOfYear);
          myCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);

          updateLabe2();




          ;
          To.setOnClickListener(new View.OnClickListener()
          @Override
          public void onClick(View view)
          new DatePickerDialog(getContext(), dateto, myCalendar
          .get(Calendar.YEAR), myCalendar.get(Calendar.MONTH),
          myCalendar.get(Calendar.DAY_OF_MONTH)).show();

          );
          public void updateLabe2()

          String myFormat = "yyyy-MM-dd"; //In which you need put here
          SimpleDateFormat sdf = new SimpleDateFormat(myFormat, Locale.US);
          To.setText(sdf.format(myCalendar.getTime()));
          //here To is editbox






          share|improve this answer




















          • for example, today is nov 13, when i start calendar widget, i can get month and year info because initially calendar is focused on today. but when i click button to go previous or next month, then calendar changes oct 2018 or dec 2018
            – CLANG
            Nov 12 '18 at 20:26










          • and calendar is still focused on today, nov 13. until i click date on calendar, with just swipe and click button, i cannot get renewed data of month and year.
            – CLANG
            Nov 12 '18 at 20:26











          • use this for initilizationCalendar myCalendar = Calendar.getInstance(); so now what u want??
            – Vishal Sharma
            Nov 12 '18 at 20:28











          • i want get displaying calendar's month and year data. not focused. when we click buttons beside of basic calendarview widget, at first there will be today (nov 2018) but when i click next button(exactly button that right side of "november 2018"), widget shows me dec 2018 but i cannot get date data that represents 2018-12-**.
            – CLANG
            Nov 12 '18 at 20:32










          • if you have enough time, please see pic of my edited question.
            – CLANG
            Nov 12 '18 at 20:41










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53269244%2fandroid-getting-current-calendarviews-year-month%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














           final DatePickerDialog.OnDateSetListener dateto = new DatePickerDialog.OnDateSetListener() 

          @Override
          public void onDateSet(DatePicker view, int year, int monthOfYear,
          int dayOfMonth)
          // TODO Auto-generated method stub
          myCalendar.set(Calendar.YEAR, year);
          myCalendar.set(Calendar.MONTH, monthOfYear);
          myCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);

          updateLabe2();




          ;
          To.setOnClickListener(new View.OnClickListener()
          @Override
          public void onClick(View view)
          new DatePickerDialog(getContext(), dateto, myCalendar
          .get(Calendar.YEAR), myCalendar.get(Calendar.MONTH),
          myCalendar.get(Calendar.DAY_OF_MONTH)).show();

          );
          public void updateLabe2()

          String myFormat = "yyyy-MM-dd"; //In which you need put here
          SimpleDateFormat sdf = new SimpleDateFormat(myFormat, Locale.US);
          To.setText(sdf.format(myCalendar.getTime()));
          //here To is editbox






          share|improve this answer




















          • for example, today is nov 13, when i start calendar widget, i can get month and year info because initially calendar is focused on today. but when i click button to go previous or next month, then calendar changes oct 2018 or dec 2018
            – CLANG
            Nov 12 '18 at 20:26










          • and calendar is still focused on today, nov 13. until i click date on calendar, with just swipe and click button, i cannot get renewed data of month and year.
            – CLANG
            Nov 12 '18 at 20:26











          • use this for initilizationCalendar myCalendar = Calendar.getInstance(); so now what u want??
            – Vishal Sharma
            Nov 12 '18 at 20:28











          • i want get displaying calendar's month and year data. not focused. when we click buttons beside of basic calendarview widget, at first there will be today (nov 2018) but when i click next button(exactly button that right side of "november 2018"), widget shows me dec 2018 but i cannot get date data that represents 2018-12-**.
            – CLANG
            Nov 12 '18 at 20:32










          • if you have enough time, please see pic of my edited question.
            – CLANG
            Nov 12 '18 at 20:41















          0














           final DatePickerDialog.OnDateSetListener dateto = new DatePickerDialog.OnDateSetListener() 

          @Override
          public void onDateSet(DatePicker view, int year, int monthOfYear,
          int dayOfMonth)
          // TODO Auto-generated method stub
          myCalendar.set(Calendar.YEAR, year);
          myCalendar.set(Calendar.MONTH, monthOfYear);
          myCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);

          updateLabe2();




          ;
          To.setOnClickListener(new View.OnClickListener()
          @Override
          public void onClick(View view)
          new DatePickerDialog(getContext(), dateto, myCalendar
          .get(Calendar.YEAR), myCalendar.get(Calendar.MONTH),
          myCalendar.get(Calendar.DAY_OF_MONTH)).show();

          );
          public void updateLabe2()

          String myFormat = "yyyy-MM-dd"; //In which you need put here
          SimpleDateFormat sdf = new SimpleDateFormat(myFormat, Locale.US);
          To.setText(sdf.format(myCalendar.getTime()));
          //here To is editbox






          share|improve this answer




















          • for example, today is nov 13, when i start calendar widget, i can get month and year info because initially calendar is focused on today. but when i click button to go previous or next month, then calendar changes oct 2018 or dec 2018
            – CLANG
            Nov 12 '18 at 20:26










          • and calendar is still focused on today, nov 13. until i click date on calendar, with just swipe and click button, i cannot get renewed data of month and year.
            – CLANG
            Nov 12 '18 at 20:26











          • use this for initilizationCalendar myCalendar = Calendar.getInstance(); so now what u want??
            – Vishal Sharma
            Nov 12 '18 at 20:28











          • i want get displaying calendar's month and year data. not focused. when we click buttons beside of basic calendarview widget, at first there will be today (nov 2018) but when i click next button(exactly button that right side of "november 2018"), widget shows me dec 2018 but i cannot get date data that represents 2018-12-**.
            – CLANG
            Nov 12 '18 at 20:32










          • if you have enough time, please see pic of my edited question.
            – CLANG
            Nov 12 '18 at 20:41













          0












          0








          0






           final DatePickerDialog.OnDateSetListener dateto = new DatePickerDialog.OnDateSetListener() 

          @Override
          public void onDateSet(DatePicker view, int year, int monthOfYear,
          int dayOfMonth)
          // TODO Auto-generated method stub
          myCalendar.set(Calendar.YEAR, year);
          myCalendar.set(Calendar.MONTH, monthOfYear);
          myCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);

          updateLabe2();




          ;
          To.setOnClickListener(new View.OnClickListener()
          @Override
          public void onClick(View view)
          new DatePickerDialog(getContext(), dateto, myCalendar
          .get(Calendar.YEAR), myCalendar.get(Calendar.MONTH),
          myCalendar.get(Calendar.DAY_OF_MONTH)).show();

          );
          public void updateLabe2()

          String myFormat = "yyyy-MM-dd"; //In which you need put here
          SimpleDateFormat sdf = new SimpleDateFormat(myFormat, Locale.US);
          To.setText(sdf.format(myCalendar.getTime()));
          //here To is editbox






          share|improve this answer












           final DatePickerDialog.OnDateSetListener dateto = new DatePickerDialog.OnDateSetListener() 

          @Override
          public void onDateSet(DatePicker view, int year, int monthOfYear,
          int dayOfMonth)
          // TODO Auto-generated method stub
          myCalendar.set(Calendar.YEAR, year);
          myCalendar.set(Calendar.MONTH, monthOfYear);
          myCalendar.set(Calendar.DAY_OF_MONTH, dayOfMonth);

          updateLabe2();




          ;
          To.setOnClickListener(new View.OnClickListener()
          @Override
          public void onClick(View view)
          new DatePickerDialog(getContext(), dateto, myCalendar
          .get(Calendar.YEAR), myCalendar.get(Calendar.MONTH),
          myCalendar.get(Calendar.DAY_OF_MONTH)).show();

          );
          public void updateLabe2()

          String myFormat = "yyyy-MM-dd"; //In which you need put here
          SimpleDateFormat sdf = new SimpleDateFormat(myFormat, Locale.US);
          To.setText(sdf.format(myCalendar.getTime()));
          //here To is editbox







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 12 '18 at 20:14









          Vishal Sharma

          7762212




          7762212











          • for example, today is nov 13, when i start calendar widget, i can get month and year info because initially calendar is focused on today. but when i click button to go previous or next month, then calendar changes oct 2018 or dec 2018
            – CLANG
            Nov 12 '18 at 20:26










          • and calendar is still focused on today, nov 13. until i click date on calendar, with just swipe and click button, i cannot get renewed data of month and year.
            – CLANG
            Nov 12 '18 at 20:26











          • use this for initilizationCalendar myCalendar = Calendar.getInstance(); so now what u want??
            – Vishal Sharma
            Nov 12 '18 at 20:28











          • i want get displaying calendar's month and year data. not focused. when we click buttons beside of basic calendarview widget, at first there will be today (nov 2018) but when i click next button(exactly button that right side of "november 2018"), widget shows me dec 2018 but i cannot get date data that represents 2018-12-**.
            – CLANG
            Nov 12 '18 at 20:32










          • if you have enough time, please see pic of my edited question.
            – CLANG
            Nov 12 '18 at 20:41
















          • for example, today is nov 13, when i start calendar widget, i can get month and year info because initially calendar is focused on today. but when i click button to go previous or next month, then calendar changes oct 2018 or dec 2018
            – CLANG
            Nov 12 '18 at 20:26










          • and calendar is still focused on today, nov 13. until i click date on calendar, with just swipe and click button, i cannot get renewed data of month and year.
            – CLANG
            Nov 12 '18 at 20:26











          • use this for initilizationCalendar myCalendar = Calendar.getInstance(); so now what u want??
            – Vishal Sharma
            Nov 12 '18 at 20:28











          • i want get displaying calendar's month and year data. not focused. when we click buttons beside of basic calendarview widget, at first there will be today (nov 2018) but when i click next button(exactly button that right side of "november 2018"), widget shows me dec 2018 but i cannot get date data that represents 2018-12-**.
            – CLANG
            Nov 12 '18 at 20:32










          • if you have enough time, please see pic of my edited question.
            – CLANG
            Nov 12 '18 at 20:41















          for example, today is nov 13, when i start calendar widget, i can get month and year info because initially calendar is focused on today. but when i click button to go previous or next month, then calendar changes oct 2018 or dec 2018
          – CLANG
          Nov 12 '18 at 20:26




          for example, today is nov 13, when i start calendar widget, i can get month and year info because initially calendar is focused on today. but when i click button to go previous or next month, then calendar changes oct 2018 or dec 2018
          – CLANG
          Nov 12 '18 at 20:26












          and calendar is still focused on today, nov 13. until i click date on calendar, with just swipe and click button, i cannot get renewed data of month and year.
          – CLANG
          Nov 12 '18 at 20:26





          and calendar is still focused on today, nov 13. until i click date on calendar, with just swipe and click button, i cannot get renewed data of month and year.
          – CLANG
          Nov 12 '18 at 20:26













          use this for initilizationCalendar myCalendar = Calendar.getInstance(); so now what u want??
          – Vishal Sharma
          Nov 12 '18 at 20:28





          use this for initilizationCalendar myCalendar = Calendar.getInstance(); so now what u want??
          – Vishal Sharma
          Nov 12 '18 at 20:28













          i want get displaying calendar's month and year data. not focused. when we click buttons beside of basic calendarview widget, at first there will be today (nov 2018) but when i click next button(exactly button that right side of "november 2018"), widget shows me dec 2018 but i cannot get date data that represents 2018-12-**.
          – CLANG
          Nov 12 '18 at 20:32




          i want get displaying calendar's month and year data. not focused. when we click buttons beside of basic calendarview widget, at first there will be today (nov 2018) but when i click next button(exactly button that right side of "november 2018"), widget shows me dec 2018 but i cannot get date data that represents 2018-12-**.
          – CLANG
          Nov 12 '18 at 20:32












          if you have enough time, please see pic of my edited question.
          – CLANG
          Nov 12 '18 at 20:41




          if you have enough time, please see pic of my edited question.
          – CLANG
          Nov 12 '18 at 20:41

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53269244%2fandroid-getting-current-calendarviews-year-month%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          這個網誌中的熱門文章

          Barbados

          How to read a connectionString WITH PROVIDER in .NET Core?

          Node.js Script on GitHub Pages or Amazon S3