First pass this information from your first Activity:
int numberOfPlayers;
Get the number of players from your spinner, however you currently do that set it to numberOfPlayers
Then pass this when you start your new Activity
Intent getPlayerNamesIntent = new Intent(MainActivity.this, PLayerNamesActivity.class);
getPlayerNamesIntent.putExtra("NUM_PLAYERS", numberOfPlayers);
startActivity(getPlayerNamesIntent);
Then in the next Activity onCreate get your Extras
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
// Layout should create have something like LinearLAyout with orientation vertical with name android:id="@+id/linearLayoutParent"
setContentView(R.layout.base_layout);
LinearLayout layout = (LinearLayout) findViewById(R.id.linearLayoutParent);
// get the NUmber from extras
int numberOfPlayers = getIntent().getExtras().getInt("NUM_PLAYERS");
if(numberOfPlayers > 0){
for(int i = 0; i < numberOfPlayers; i++){
EditText editText = new EditText(this);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
editText.setLayoutParams(params);
// Set Tag here, so you can use tag to get the right player later
editText.setTag("PlayerNumber_" + Integer.toString(i));
layout.addView(editText);
}
}
}