Answer the question
In order to leave comments, you need to log in
How to form a normal table?
I don’t know how to form a table, I tried TableLayout
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
stroka = (TextView) findViewById(R.id.info);
TableLayout tableLayout = new TableLayout(this);
tableLayout.setLayoutParams(new TableLayout.LayoutParams(
ViewGroup.LayoutParams.FILL_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT
));
tableLayout.setStretchAllColumns(true);
try {
TextView textView[] = new TextView[9];
TableRow tableRow[] = new TableRow[3];
for (int i = 0; i < 9; i++) {
textView[i] = new TextView(this);
textView[i].setText("Stroka " + i);
}
int l = 0;
for (int i = 0; i < 3; i++) {
tableRow[i] = new TableRow(this);
for (int j = 0; j < 3; l++, j++) tableRow[i].addView(textView[l]);
}
for (int i = 0; i < 3; i++) {
tableLayout.addView(tableRow[i]);
}
setContentView(tableLayout);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question