title: How to get items from adapter and pass it in activity android?
body: <p>I am using <code>retrofit</code> where I have request in List type. </p>
  
  <pre><code> public RequestBody(String msisdn, List&lt;RoutePlanDayRequests&gt; routePlanDayRequests ) {
          this.msisdn = msisdn;
          this.routePlanDayRequests = routePlanDayRequests;
      }
  </code></pre>
  
  <p>So this RoutePlanDayRequests has following pojo classes.   </p>
  
  <pre><code>public class RoutePlanDayRequests {
  
      private String status;
  
      private String oldDay;
  
      private String neweDay;
  
  
      public String getOldDay() {
          return oldDay;
      }
  
      public void setOldDay(String oldDay) {
          this.oldDay = oldDay;
      }
  
      public String getNeweDay() {
          return neweDay;
      }
  
      public void setNeweDay(String neweDay) {
          this.neweDay = neweDay;
      }
  }
  </code></pre>
  
  <p>So I am calling one web service to display the list in adapter.Now I am getting the response in adapter class and <strong><em>submit button in MainActivity.</em></strong> So when i change the spinner for other days and submit, how to get this items from adapter and pass the data in MainActivity?</p>
  
  <p>Because in adapter class it has spinner where items get changed based on spinner selection. So those items when changed I need to submit. But problem is submit button is in MainActivity. So how to pass those item values in MainActivity?</p>
  
  <p>MainActivity.class:</p>
  
  <pre><code> @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
   setcontentView(R.layout.main);
  
  initialLoadingServiceList(); //this is to load initial items
  
   submitChangeRequest.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  //here I have been strucked.
                  updateServiceList();
              }
          });
  
   private void updateServiceList() {
          List&lt;RoutePlanDayRequests&gt; request = null;
          //strucked to get the spinner values to pass in request.
          RetrofitInstance.getInstance(this)
                  .create(RoutePlanService.class)
                  .getSaveRoutePlanDay(new SaveDayRequest(new RequestBody("",request)) //here I need to pass the changed item values from adapter to here. 
      }
  }
  
  //Hope you got it my requirement. 
  
  public void initialLoadingServiceList(){
  //skipping service list.. 
  
      RoutePlanVisitChangeAdapter adapter = new RoutePlanVisitChangeAdapter(retailers, RoutePlanVisitChangeActivity.this);
                                          mRecyclerView.setAdapter(adapter);
  
  }
  
  
  }
  </code></pre>
  
  <p>Adapter class:</p>
  
  <pre><code>public class RoutePlanVisitChangeAdapter extends RecyclerView.Adapter&lt;RoutePlanVisitChangeAdapter.RoutePlanVisitChangeView&gt; {
      private List&lt;Retailers&gt; mList;
      private Context context;
      private String[] daysList = {"MON", "TUE", "WED", "THU", "FRI", "SAT"};
  
      public RoutePlanVisitChangeAdapter(List&lt;Retailers&gt; list, Context context) {
          this.mList = list;
          this.context = context;
      }
  
  
      @Override
      public RoutePlanVisitChangeView onCreateViewHolder(ViewGroup parent, int viewType) {
          View view;
          view = LayoutInflater.from(parent.getContext()).inflate(R.layout.route_plan_visit_change_row, parent, false);
          return new RoutePlanVisitChangeView(view);
      }
  
      @Override
      public void onBindViewHolder(RoutePlanVisitChangeView holder, int position) {
          Retailers routePlanVisitChange = mList.get(position);
          holder.retailerName.setText(routePlanVisitChange.getName());
          holder.retailerNumber.setText(routePlanVisitChange.getMsisdn());
          holder.fromDay.setText(routePlanVisitChange.getRoutePlanDayOfWeek());
          String profileUrl = routePlanVisitChange.getProfileImage().getImageUrl();
          Glide.with(context)
                  .load(profileUrl)
                  .placeholder(R.drawable.ic_default_profile)
                  .error(R.drawable.ic_default_profile)
                  .into((holder.profileImage));
  
          String getRoutePlanDay = routePlanVisitChange.getRoutePlanDayOfWeek().toUpperCase();
          List&lt;String&gt; asSet = new ArrayList&lt;String&gt;(Arrays.asList(daysList));
          asSet.remove(getRoutePlanDay);
          String[] newDayList = asSet.toArray(new String[]{});
          ArrayAdapter updatedData = new ArrayAdapter(context, android.R.layout.simple_spinner_item, newDayList);
          updatedData.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
          holder.toDay.setAdapter(updatedData); //so now i changed the values in spinner. I need to update in button click in main activity
          String selectedSpinner = holder.toDay.getSelectedItem().toString();
      }
  
      @Override
      public int getItemCount() {
          if (mList == null)
              return 0;
          return mList.size();
      }
  
      public class RoutePlanVisitChangeView extends RecyclerView.ViewHolder {
  
          public TextView retailerName;
          public TextView retailerNumber;
          public AppCompatButton fromDay;
          public Spinner toDay;
          public CircleImageView profileImage;
  
          public RoutePlanVisitChangeView(View view) {
              super(view);
              retailerName = (TextView) 
              view.findViewById(R.id.recycle_txt_acc_name);
              retailerNumber = (TextView) 
              view.findViewById(R.id.recycle_txt_acc_num);
              fromDay = (AppCompatButton) view.findViewById(R.id.from_day);
              toDay = (Spinner) view.findViewById(R.id.to_day);
              profileImage = (CircleImageView) view.findViewById(R.id.recycle_profile);
              //toDay = (AppCompatButton) view.findViewById(R.id.to_day);
          }
      }
      public Retailers getItem(int position) {
          return mList.get(position);
          }
       }
     }
  </code></pre>
  
  <p>Kindly suggest/ resolve my issue please. Struck badly how to get items in MainActivity from adapter class. </p>