how to get position from programmatically created spinners
===

when the user enters a number in a edittext my app then creates and displays that many spinners. The user will then select an item from each spinner and then click a save button. I have looked on the internet but have been unable to find a way to retrieve the position from the spinners. Here is how I created the spinners:

    //numStockTanks is the number of spinners to be created
    numStockTanks = Integer.parseInt(numOfStockTanks.getText().toString());				
		// creates all the fields
     	for(int i = 1; i <= numStockTanks; i++) {
    		TableRow tR = new TableRow(this);
        	// creates the textView
        	tV1 = new TextView(this);
            tV1.setText("Stock Tank #" + i + " size: ");
                       
            // add spinner to row
            spinner = new Spinner(this);
            ArrayAdapter<CharSequence> adapterStockTankSize2 = ArrayAdapter.createFromResource(
                    this, R.array.StockTankSize, android.R.layout.simple_spinner_item);
            adapterStockTankSize2.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
            spinner.setAdapter(adapterStockTankSize2);
            spinner.setId(1000 + i);
       
            // add the TextView and the editText to the new TableRow
            tR.addView(tV1);
            tR.addView(spinner);
                 
            // add the TableRow to the TableLayout
            tL.addView(tR,new TableLayout.LayoutParams(
            		LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));    
        } // end for statement
	} // end getNumberCreateSpinner ()

I have attemped several different way to get the position of the spinners but I cant seem to figure it out. Here is what I currently have:

    ArrayList<Integer> mArraySpinner = new ArrayList<Integer>();
    for (int i = 0; i < numStockTanks; i++) {
			   spinner = (Spinner) findViewById(1000 + i);
			   if (spinner.getId().equals("100")) {
				   mArraySpinner.add(spinner.getSelectedItemPosition());
			   } else if (spinner.getId().equals("200")) {
				   mArraySpinner.add(spinner.getSelectedItemPosition());
			   } else if (spinner.getId().equals("210")) {
				   mArraySpinner.add(spinner.getSelectedItemPosition());
			  } else if (spinner.getId().equals("295")) {
				   mArraySpinner.add(spinner.getSelectedItemPosition());
			   } else if (spinner.getId().equals("400")) {
				   mArraySpinner.add(spinner.getSelectedItemPosition());
			  } else mArraySpinner.add("0");
		} // end for statement

Thanks for your help
