My goal is to generate the layout of a view in Android Studios dynamically. The ultimate goal is to dynamically generate the following view
number - name - role
all on one line.
This is the current background code in Android Studio, which is currently setting the layout as follows
number
name
role
CODE
private void GenerateLayout()
{
llisroles = findViewById(R.id.llRoles);
for (int x = 0; x < num_players; x++)
{
TextView number = new TextView(this);
EditText name = new EditText(this);
Spinner role = new Spinner(this);
//number.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
//name.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
number.setText(names_players[x]);
name.setText("");
llisroles.addView (number);
llisroles.addView(name);
llisroles.addView(role);
}
}