Dies ist mein Gridlayout
Code: Select all

And this is how it should like with data:
, aber nach dem Hinzufügen mit diesem Code:
Code: Select all
int i = 2;
loading=false;
GridLayout.Spec col2 = GridLayout.spec(2);
GridLayout.Spec col3 = GridLayout.spec(3);
GridLayout.Spec col4 = GridLayout.spec(4);
GridLayout.Spec colspan2 = GridLayout.spec(0, 1);
grdTeamAPlayers.setColumnCount(5);
grdTeamAPlayers.setRowCount(teamAPlayers.size()+2);
for(TournamentPlayer newPlayer: teamAPlayers)
{
GridLayout.Spec row = GridLayout.spec(i);
GridLayout.LayoutParams first = new GridLayout.LayoutParams(row, colspan2);
GridLayout.LayoutParams goals = new GridLayout.LayoutParams(row, col2);
GridLayout.LayoutParams yellow = new GridLayout.LayoutParams(row, col3);
GridLayout.LayoutParams red = new GridLayout.LayoutParams(row, col4);
TextView newName = new TextView(myContext);
newName.setText(newPlayer.getName() + " " + newPlayer.getLastName());
newName.setTextColor(ContextCompat.getColor(myContext, R.color.black_50));
newName.setTextSize(14);
newName.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
grdTeamAPlayers.addView(newName, first);
TextView newGoals = new TextView(myContext);
newGoals.setText(newPlayer.getGoals() + "");
newName.setTextSize(14);
newGoals.setTextColor(ContextCompat.getColor(myContext, R.color.black_50));
newGoals.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
TextView newYellow = new TextView(myContext);
newYellow.setText(newPlayer.getYellowCards() + "");
newName.setTextSize(14);
newYellow.setTextColor(ContextCompat.getColor(myContext, R.color.black_50));
newYellow.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
TextView newRed = new TextView(myContext);
newRed.setText(newPlayer.getRedCards()+"");
newName.setTextSize(14);
newRed.setTextColor(ContextCompat.getColor(myContext, R.color.black_50));
newRed.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
grdTeamAPlayers.addView(newGoals, goals);
grdTeamAPlayers.addView(newYellow, yellow);
grdTeamAPlayers.addView(newRed, red);
i=i+1;
}