title: How can I control the Recycle View by clicking on the date of the calendar view?
body: <p>I'm new in android and also new in English sorry my bad English...
  I have learned android course at the academy.
  My sentence may be wrong because it is written through a translator. I hope you understand with a generous heart. </p>
  
  <p>Here's what I want:</p>
  
  <p>If I click 15 days in Calendar View, 
  It is hoped that only the 15th day information will be shown in the Recyclerview. If I click on another date in calenderview, for example, 20 days, I hope that the 15th item will disappear and only the 20th item view will be displayed.</p>
  
  <p>Here's what I'm trying to do.
  When I click a date in a calendar view, I want to see the Item View corresponding to that date.</p>
  
  <ul>
  <li><p>package com.example.myapplication;</p>
  
  <p>import android.app.Activity;
  import android.content.Context;
  import android.content.Intent;
  import android.content.SharedPreferences;
  import android.icu.util.Calendar;
  import android.support.v7.app.AlertDialog;
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.support.v7.widget.DividerItemDecoration;
  import android.support.v7.widget.LinearLayoutManager;
  import android.support.v7.widget.RecyclerView;
  import android.util.Log;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.widget.Button;
  import android.widget.CalendarView;
  import android.widget.EditText;
  import android.widget.TextView;
  import android.widget.Toast;</p>
  
  <p>import java.text.SimpleDateFormat;
  import java.util.ArrayList;
  import java.util.Date;</p>
  
  <p>public class Calender extends AppCompatActivity {</p>
  
  <pre><code>// CalendarView myCalenderView;
  
  // TextView schedule1, schedule11;
  
  String a, b, c;
  
  static String data1;
  long Now;
  Date date;
  java.text.SimpleDateFormat mFormat = new SimpleDateFormat("YYYY_MM_dd");
  
  TextView datetext;
  
  Context mcontext;
  
  private String getTime() {
      Now = System.currentTimeMillis();
      date = new Date(Now);
      return mFormat.format(date);
  }
  
  
  private ArrayList&lt;calenderArrayList&gt; mArrayList = new ArrayList&lt;&gt;();
  
  private ArrayList&lt;calenderArrayList&gt; bArrayList = new ArrayList&lt;&gt;();
  
  
  SharedPreferences preferences;
  
  SharedPreferences.Editor editor;
  
  
  private static String TAG = "recyclerview_example";
  
  //private ArrayList&lt;calenderArrayList&gt; mArrayList;
  
  //ArrayList 선언
  
  calendarAdapter mAdapter = new calendarAdapter(this, mArrayList);
  //mAdapter 선언
  
  //  calendarAdapter bAdapter = new calendarAdapter(this, bArrayList);
  private RecyclerView mRecyclerView;
  
  
  private LinearLayoutManager mLinearLayoutManager;
  
  private int count = 0;
  
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_calender);
  
      Log.d("스케쥴선택액티비티", "OnCreate()실행");
  
  
      SharedPreferences calender_load = getSharedPreferences("calender", MODE_PRIVATE);
  
      calender_load.getInt("save_size", 0);
  
      int calender_size = calender_load.getInt("save_size", 0);
      Log.d("시작시b사이즈1", "" + calender_size);
      Log.d("시작시b사이즈1", "" + bArrayList.size());
      Log.d("시작시m사이즈1", "" + mArrayList.size());
      if (calender_size != 0) {
  
          for (int i = 0; i &lt; calender_size; i++) {
  
  
              calenderArrayList calender = new calenderArrayList(calender_load.getString("save_date" + i, ""), calender_load.getString("save_work" + i, ""), calender_load.getString("save_place" + i, ""), calender_load.getBoolean("save_box" + i, false));
  
              if (calender.number_exam.equals(data1)) {
                  Log.d("불러오기값", "" + calender_load.getString("save_date" + i, ""));
  
                  bArrayList.add(calender);
                  mArrayList.add(calender);
              }
              mAdapter = new calendarAdapter(this, mArrayList);
  
              mAdapter.notifyDataSetChanged();
          }
      } else if (calender_size == 0) {
  
          mAdapter = new calendarAdapter(this, mArrayList);
          mAdapter.notifyDataSetChanged();
      }
  
  
      mRecyclerView = (RecyclerView) findViewById(R.id.recycler_view_exam);
      //recycler_view라는 id를 가진 recycler_view를 mRecyclerView로 지정해준다.
  
      mRecyclerView.addItemDecoration(new DividerItemDecoration(mRecyclerView.getContext(), 1));
  
  
      mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
  
  
      //RecyclerView 내에 Item view들의 크기를 측정하고 위치를 지정
      //언제 item view를 재사용해야하는지에 대한 정책을 결정하고 결정.
  
      //mArrayList = new ArrayList&lt;&gt;();
  
  
      mAdapter = new calendarAdapter(this, mArrayList);
      //RecyclerView 내에 보여지는 view 들에 date set을 binding 시켜주는 역할.
      //binding? 데이터 끼리 묵어준다?
  
      mRecyclerView.setAdapter(mAdapter);
      //mRecyclerView의 Adapter를 mAdapter로 set한다.
      //set? 지정한다. 놓다. 위치하다.
  
  
      // myCalenderView = (CalendarView) findViewById(R.id.calendar);
  
  
  }
  
  
  @Override
  protected void onStart() {
      // TODO Auto-generated method stub
      super.onStart();
      //   Toast.makeText(getApplicationContext(), "onStart()", Toast.LENGTH_SHORT).show();
  
  
      Log.d("스케쥴선택액티비티", "OnStart()실행");
  
  
      Log.d("스케쥴선택액티비티", "OnResume()실행");
  
  
  }
  
  
  @Override
  protected void onResume() {
      // TODO Auto-generated method stub
      super.onResume();
      //  Toast.makeText(getApplicationContext(), "onResume()", Toast.LENGTH_SHORT).show();
  
      final CalendarView calendar = (CalendarView) findViewById(R.id.calendar);
      calendar.setOnDateChangeListener(new CalendarView.OnDateChangeListener() {
          @Override
          public void onSelectedDayChange(CalendarView view, int year, int month, int dayOfMonth) {
  
              data1 = year + "/" + (month + 1) + "/" + dayOfMonth;
  
              String a = data1 + dayOfMonth;
              Log.d("날짜", "" + a);
              ArrayList&lt;calenderArrayList&gt; dayofMonth = new ArrayList&lt;&gt;();
  
              Log.d("어떤 이름으로?", "" + dayofMonth);
              if (dayofMonth.size() != 0) {
  
                  SharedPreferences load = getSharedPreferences("" + data1, MODE_PRIVATE);
  
  
              }
  
             /* if(mArrayList.size()!=0) {
                  for (int i=0; i&lt;mArrayList.size() ; i++) {
                      SharedPreferences save11 = getSharedPreferences("save", MODE_PRIVATE );
                      SharedPreferences.Editor save_editor = save11.edit();
  
                      save_editor.putBoolean("save_box"+i+mArrayList.get(i).number_exam, mArrayList.get(i).selected );
                      save_editor.putString("save_date"+i+mArrayList.get(i).number_exam, mArrayList.get(i).number_exam);
  
                      save_editor.putString("save_work"+i+mArrayList.get(i).number_exam, mArrayList.get(i).content_exam);
  
                      save_editor.putString("save_place"+i+mArrayList.get(i).number_exam, mArrayList.get(i).content_exam2);
  
                      save_editor.putInt("save_size"+mArrayList.get(i).number_exam, mArrayList.size());
  
                      save_editor.commit();
  
  
                  }
              }
              mArrayList.clear();
  
              if(mArrayList.size()!=0)
              {
                  for (int i =0; i&lt;mArrayList.size(); i++){
  
                      if(mArrayList.get(i).number_exam.equals(data1)){
  
  
                      }
  
                  }
              }*/
  
  
              //int a = dayOfMonth;
              Toast.makeText(Calender.this, year + "/" + (month + 1) + "/" + dayOfMonth, Toast.LENGTH_SHORT).show();
  
              Log.d("리사이클러뷰 실행 전", "실행 전");
              mRecyclerView = (RecyclerView) findViewById(R.id.recycler_view_exam);
              Log.d("리사이클러뷰 실행 후", "실행 후");
  
  
              final EditText number_exam = (EditText) view.findViewById(R.id.calender_date);
              final EditText content_exam = (EditText) view.findViewById(R.id.calender_place);
              final EditText content_exam2 = (EditText) view.findViewById(R.id.calender_content);
  
              //TextView ee = findViewById(R.id.number_exam);
  
              Log.d("사이즈 측정  실행 전", "실행 전");
  
  
              ArrayList&lt;calenderArrayList&gt; calenderArrayLists = new ArrayList&lt;&gt;();
              Log.d("실행11111", mAdapter.getItemCount() + "");
  
              Log.d("뭐가 들어있나?", "" + mArrayList);
              Log.d("뭐가 들어있나?", "" + mArrayList.size());
              // Log.d("뭐가 들어았나?", ""+mArrayList.get(1).number_exam.toString());
              //  Log.d("뭐가 들어았나?", ""+mArrayList.get(2).number_exam.toString());
              // Log.d("뭐가 들어았나?", ""+mArrayList.get(3).number_exam.toString());
  
              if (mArrayList.size() != 0) {
                  Log.d("if구문 실행됨?", "" + mArrayList.size());
  
                  //1. 일단 뷰 자체를 초기화 해주어야함.
                  //2. 초기화 된 뷰에 다시 mArrayList에서 선정 된 정보를 다시 나타내주어야한다.
  
  
              /*  for(int i = 0; i&lt;mArrayList.size(); i++){
  
                      Log.d("얼마?", ""+i);
                      Log.d("for 구문 작동?실행", "여기까진 접속?");
                      if(mArrayList.get(i).number_exam.toString().contains(a)){
  
                          Log.d("뭐가 들어있나? 실행여부", ""+mArrayList.get(i).number_exam.toString());
  
  
  
  
  
                          a = mArrayList.get(i).number_exam;
  
                          b = mArrayList.get(i).content_exam;
  
                          c = mArrayList.get(i).content_exam2;
  
  
                          //mArrayList.add(mArrayList.get(i));
  
  
  
                      }
  
  
                  }*/
  
  
              }
  
          }
      });
  
  
      Button buttonInsert_exam = (Button) findViewById(R.id.exam_button);
      //button 클릭시 발생하는 이벤트를 나타낸다. 여기서는 입력하기 버튼 클릭시 발생하는 상황.
  
      buttonInsert_exam.setOnClickListener(
              new View.OnClickListener() {
                  @Override
                  public void onClick(View v) {
  
                      AlertDialog.Builder builder = new AlertDialog.Builder(Calender.this);
                      View view = LayoutInflater.from(Calender.this)
                              .inflate(R.layout.activity_calender_edit_box, null, false);
                      builder.setView(view);
                      final Button ButtonSubmit_exam = (Button) view.findViewById(R.id.button_dialog_submit_exam);
                      final EditText number_exam = (EditText) view.findViewById(R.id.calender_date);
                      final EditText content_exam = (EditText) view.findViewById(R.id.calender_place);
                      final EditText content_exam2 = (EditText) view.findViewById(R.id.calender_content);
                      // final EditText editTextKorean = (EditText) view.findViewById(R.id.edittext_dialog_korean);
  
                      ButtonSubmit_exam.setText("입력하기");
  
                      number_exam.setText(data1);
                      final AlertDialog dialog = builder.create();
  
                      dialog.show();
  
                      //dialog에 나타나는 입력하기 버튼을 눌렀을 때 발생하는 상황
                      ButtonSubmit_exam.setOnClickListener(new View.OnClickListener() {
                          public void onClick(View v) {
  
  
                              String strID = number_exam.getText().toString();
                              String strID2 = content_exam.getText().toString();
                              String strID3 = content_exam2.getText().toString();
                              //number와 content view에 입력한 문자열을 strID, strID2에 담는다.
  
                              //String strKorean = editTextKorean.getText().toString();
  
                              calenderArrayList dict = new calenderArrayList(strID, strID2, strID3);
  
                              bArrayList.add(0, dict);
                              mArrayList.add(0, dict); //첫 줄에 삽입
                              //mArrayList.add(dict); //마지막 줄에 삽입
                              mAdapter.notifyDataSetChanged(); //변경된 데이터를 화면에 반영
  
                              Log.d("b사이즈", "" + bArrayList.size());
                              Log.d("m사이즈", "" + mArrayList.size());
  
                              dialog.dismiss();
                              //dialog를 종료 시켜준다.
                          }
                      });
  
  
                  }
  
  
              });
  }
  
  
  @Override
  protected void onPause() {
      // TODO Auto-generated method stub
      super.onPause();
      //  Toast.makeText(getApplicationContext(), "onPause()", Toast.LENGTH_SHORT).show();
  
      SharedPreferences calendersave = getSharedPreferences("calender", MODE_PRIVATE);
  
      SharedPreferences.Editor calendersaveeditor = calendersave.edit();
  
      //calenderArrayList calenderArrayList = new calenderArrayList();
  
      if (bArrayList.size() != 0) {
  
          for (int i = 0; i &lt; bArrayList.size(); i++) {
  
  
              calendersaveeditor.putBoolean("save_box" + i, bArrayList.get(i).selected);
  
              calendersaveeditor.putString("save_date" + i, bArrayList.get(i).number_exam);
  
              calendersaveeditor.putString("save_work" + i, bArrayList.get(i).content_exam);
  
              calendersaveeditor.putString("save_place" + i, bArrayList.get(i).content_exam2);
  
              calendersaveeditor.putInt("save_size", bArrayList.size());
  
              calendersaveeditor.commit();
  
  
              Log.d("종료시b사이즈", "" + bArrayList.size());
              Log.d("종료시m사이즈", "" + mArrayList.size());
  
          }
  
      } else if (bArrayList.size() == 0) {
  
          calendersaveeditor.clear();
          calendersaveeditor.commit();
      }
  
      Log.d("스케쥴선택액티비티", "OnPause()실행");
  }
  
  
  @Override
  protected void onStop() {
      // TODO Auto-generated method stub
      super.onStop();
      //  Toast.makeText(getApplicationContext(), "onStop()", Toast.LENGTH_SHORT).show();
  
  
  
  
  
      /*
      * if(mArrayList.size()!=0){
  
          for(int i = 0; i&lt; mArrayList.size(); i++){
  
  
  
              calendersaveeditor.putBoolean("save_box"+i, mArrayList.get(i).selected);
  
              calendersaveeditor.putString("save_date"+i, mArrayList.get(i).number_exam);
  
              calendersaveeditor.putString("save_work"+i, mArrayList.get(i).content_exam);
  
              calendersaveeditor.putString("save_place"+i, mArrayList.get(i).content_exam2);
  
              calendersaveeditor.putInt("save_size", mArrayList.size());
  
              calendersaveeditor.commit();
  
  
          }
  
      }
  
      else if(mArrayList.size()==0){
  
          calendersaveeditor.clear();
          calendersaveeditor.commit();
      }
  </code></pre>
  
  <p>*/</p>
  
  <pre><code>    Log.d("스케쥴선택액티비티", "OnStop()실행");
  }
  
  @Override
  protected void onRestart() {
      // TODO Auto-generated method stub
      super.onRestart();
      // Toast.makeText(getApplicationContext(), "onRestart()", Toast.LENGTH_SHORT).show();
  
      Log.d("스케쥴선택액티비티", "OnRestart()실행");
  }
  
  @Override
  protected void onDestroy() {
      // TODO Auto-generated method stub
      super.onDestroy();
      // Toast.makeText(getApplicationContext(), "onDestroy()", Toast.LENGTH_SHORT).show();
  
      Log.d("스케쥴선택액티비티", "OnDestroy()실행");
  }
  </code></pre>
  
  <p>}</p></li>
  </ul>