Q:

scrolling down in recyclerview, selected items in spinner change

when user presses FAB, a cardview appears in recyclerview. Inside the cardview is a spinner with some other elements. When i add multiple cardviews and select an item from the spinners, then I add another cardview from the fab then all the spinner selected items reset?
I have a method productList.size() which could possibly help in saving the spinner selected values but I do not know where to go from here. Thanks
activity code
public class create extends AppCompatActivity {

    //a list to store all the products
    List<Product> productList;

    //the recyclerview
    RecyclerView recyclerView;

    Product mProduct;
    private Map<String, String> numberItemValues = new HashMap<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.create);

        //opens csv
        InputStream inputStream = getResources().openRawResource(R.raw.shopitems);
         CSVFile csvFile = new CSVFile(inputStream);

       final List<String>  mSpinnerItems = csvFile.read();

        //getting the recyclerview from xml
        recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
        recyclerView.setHasFixedSize(true);
        recyclerView.setLayoutManager(new LinearLayoutManager(this));

        //initializing the productlist
        productList = new ArrayList<>();

      final Spinner spinner;
      final EditText editText;
      final CheckBox checkBox;
      final TextView textView5;

      spinner = findViewById(R.id.spinner);
      editText = findViewById(R.id.editText);
      checkBox = findViewById(R.id.checkBox);
      textView5 = findViewById(R.id.textView5);

      final ProductAdapter  adapter = new ProductAdapter(this, productList);

        //TODO FAB BUTTON
        FloatingActionButton floatingActionButton =
                (FloatingActionButton) findViewById(R.id.fab);

        floatingActionButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                List<Product> mProductList = new ArrayList<>();
                productList.add(mProduct);
                if(adapter != null)
                    adapter.notifyDataSetChanged();
                //Handle the empty adapter here

            }
        });

       /* //TODO Add the spinner on item selected listener to get selected items
        spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
            @Override
            public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) {
                String currentItem = mSpinnerItems.get(position);
                String aisleNumber = numberItemValues.get(currentItem);
                //TODO you can use the above aisle number to add to your text view
                //mTextviews.get(mTextviews.size() -1).setText(aisleNumber);
                textView5.setText(aisleNumber);
            }

            @Override
            public void onNothingSelected(AdapterView<?> parentView) {
                //  do nothing
            }
        });*/

        //setting adapter to recyclerview
        recyclerView.setAdapter(adapter);

    }

    private class CSVFile {
        InputStream inputStream;

        public CSVFile(InputStream inputStream) {
            this.inputStream = inputStream;
        }

        public List<String> read() {
// The problem with your adapter is solved now you need to do some work here its giving an error while reading the file
            //why is it giving an error because it use to work fine before I added cardview and recyclerview
            //Is the file there?
            List<String> resultList = new ArrayList<String>();
            BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
            try {
                String line;
                while ((line = reader.readLine()) != null) {
                    String[] row = line.split(",");
                    //TODO I edited this part so that you'd add the values in our new hash map variable

                    numberItemValues.put(row[1], row[0]);

                    resultList.add(row[1]);
                }
            } catch (IOException e) {
                Log.e("Main", e.getMessage());
            } finally {
                try {
                    inputStream.close();
                } catch (IOException e) {
                    Log.e("Main", e.getMessage());
                }
            }
            return resultList;
        }
    }

}

product.java code
public class Product {

    private static String editText;
    private static Boolean checkBox;
    private static String textView5;

    // The following list is useless unless u don't use it somewhere so lets create getters and setters for this item
    public static List<String> spinnerItemsList = new ArrayList<String>();

    public Product(List spinner, String editText, Boolean checkBox, String textView5) {

        this.editText = editText;
        this.spinnerItemsList = spinner;
        this.checkBox = checkBox;
        this.textView5 = textView5;
    }
    public static String getEdittext () {
        return editText;
    }

    public static boolean getCheckbox () {
        return checkBox;
    }

    public static String getTextview () {
        return textView5;
    }
    public static List<String> getSpinnerItemsList () {
        return spinnerItemsList;
    }
}

productadapter.java
public class ProductAdapter extends RecyclerView.Adapter<ProductAdapter.ProductViewHolder> {

    //this context we will use to inflate the layout
    private Context mCtx;
    private Spinner spinner;

    //we are storing all the products in a list
    private List<Product> productList;

    //getting the context and product list with constructor
    public ProductAdapter(Context mCtx, List<Product> productList) {
        this.mCtx = mCtx;
        this.productList = productList;
    }

    @Override
    public ProductViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        //inflating and returning our view holder
        LayoutInflater inflater = LayoutInflater.from(mCtx);
        View view = inflater.inflate(R.layout.layout_products, null);
        return new ProductViewHolder(view);
    }

    @Override
    public void onBindViewHolder(ProductViewHolder holder, int position) {
        //getting the product of the specified position
        Product product = productList.get(position);

        //binding the data with the viewholder views

        //MyListAdapter adapter = new MyListAdapter(mCtx, R.layout.listrow, R.id.txtid, Product.spinnerItemsList);
        //spinner.setAdapter(adapter);
        //Try using Simple ArrayAdapter if all you need to display is one text
        //Lets see
        ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String> (mCtx, android.R.layout.simple_spinner_item, Product.getSpinnerItemsList());
        spinnerArrayAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
       //Did it work?
        //yes but when I press the spinner I do not see the items that usually comes up also the layout of Oit Oipen the screen let me take the screen shot
        //how do i do that? the screen is open on my phone ok wait click the spinner yes
        //There is no item??
        //nothing comes up. not even a dropdown. but before i had it like it was populated by items in a csv.
        //Okay wait let me get your old code

        //also, I added cardviews in my phone but i try to scroll up and I cannot? i thought you could scroll in recyclerview?
        //Yes you can scroll it should work

        holder.spinner.setAdapter(spinnerArrayAdapter);
    }

    @Override
    public int getItemCount() {
        return productList.size();
    }

    class ProductViewHolder extends RecyclerView.ViewHolder {

        Spinner spinner;
        EditText editText;
        TextView textView5;
        CheckBox checkBox;

        public ProductViewHolder(View itemView) {
            super(itemView);

            spinner = itemView.findViewById(R.id.spinner);
            editText = itemView.findViewById(R.id.editText);
            textView5 = itemView.findViewById(R.id.textView5);
            checkBox = itemView.findViewById(R.id.checkBox);
        }
    }
}

**mylistadapter.java which is for spinner **
public class MyListAdapter extends ArrayAdapter<String> {
    int groupid;
    List<String> items;
    Context context;
    String path;

    public MyListAdapter(Context context, int vg, int id, List<String> items) {
        super(context, vg, id, items);
        this.context = context;
        groupid = vg;
        this.items = items;

    }

    static class ViewHolder {
        public TextView textid;
        public TextView textname;

    }

    @Override
    public View getDropDownView(int position, View convertView, ViewGroup parent) {
        {

            View rowView = convertView;
            if (rowView == null) {
                LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                rowView = inflater.inflate(groupid, parent, false);
                ViewHolder viewHolder = new ViewHolder();
                viewHolder.textid = (TextView) rowView.findViewById(R.id.txtid);
                viewHolder.textname = (TextView) rowView.findViewById(R.id.txtname);
                rowView.setTag(viewHolder);
            }
            // Fill data in the drop down.
            ViewHolder holder = (ViewHolder) rowView.getTag();
            String row = items.get(position);
            //holder.textid.setText(row[0]); //prints aisle number, dont need

            holder.textname.setText(row);

            return rowView;
        }

    }

}

A:

There are multiple steps to achieve this:
Step 1:
Map<Integer, Integer> mSpinnerSelectedItem = new HashMap<Integer, Integer>();

Step 2:
Inside onBindViewHolder add the following lines
if (mSpinnerSelectedItem.containsKey(position)) {
   spinner.setSelection(mSpinnerSelectedItem.get(position));
} 

Step 3: 
Now where you have set your spinner onItemSelected method add the following line to store your selected item for that spinner. 
mSpinnerSelectedItem.put(position, selectedIndex);

