Как добавить два параметра макета в addView()? Например: я создал первый TableRow.LayoutParams с полями для строк и второй TableRow.LayoutParams с диапазоном. А потом я хочу, чтобы добавить эти два параметра addView()Добавьте два параметра компоновки в addView()
Вот мой код:
import android.graphics.Color;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
TableLayout tableLayout = new TableLayout(this);
TableRow.LayoutParams tableRowParams = new TableRow.LayoutParams();
TableRow.LayoutParams tableRowParams2= new TableRow.LayoutParams();
tableRowParams.setMargins(1, 1, 1, 1);
tableRowParams2.span = 2;
TableRow row1 = new TableRow(this);
TableRow row2 = new TableRow(this);
TextView text1 = new TextView(this);
text1.setText("text1");
text1.setBackgroundColor(Color.GRAY);
TextView text2 = new TextView(this);
text2.setText("text2");
text2.setBackgroundColor(Color.GRAY);
TextView text3 = new TextView(this);
text3.setText("text3");
text3.setBackgroundColor(Color.GRAY);
TextView text4 = new TextView(this);
text4.setText("text4");
text4.setBackgroundColor(Color.GRAY);
TextView text5 = new TextView(this);
text5.setText("text5");
text5.setBackgroundColor(Color.GRAY);
TextView text6 = new TextView(this);
text6.setText("text6");
text6.setBackgroundColor(Color.GRAY);
row1.addView(text1, tableRowParams);
row1.addView(text2, tableRowParams2);
row2.addView(text4, tableRowParams);
row2.addView(text5, tableRowParams);
row2.addView(text6, tableRowParams);
tableLayout.addView(row1);
tableLayout.addView(row2);
setContentView(tableLayout);
}
}
Как я могу добавить два параметра для row1.addView()?
Я рад, что смог помочь :) – RafaelC