i动态创建表布局。现在,如果屏幕是横向或纵向,我想更改特定列的可见性。我的代码可以吗?
感谢您的帮助。
for (Element row : rows) {
TableRow eins = new TableRow(this);
Elements cells=row.select("td");
for (Element cell : cells) {
TextView tv = new TextView(this);
if (cell.select("img").size() > 0) {
tv.setText("A ");
}
else {
tv.setText(" " + cell.text() + " ");
}
if (tv.length() < 9) {
tv.setGravity(Gravity.CENTER_HORIZONTAL);
}
eins.addView(tv);
}
tbl.addView(eins);
}
如果是定向运算符
int orientation = getResources().getConfiguration().orientation;
if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
// In landscape
} else {
// In portrait
}
亲自搞定。
int orientation = getResources().getConfiguration().orientation;
if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
tbl.setColumnCollapsed(0, true);
// In landscape
} else {
tbl.setColumnCollapsed(0, true);
tbl.setColumnCollapsed(4, true);
tbl.setColumnCollapsed(5, true);
tbl.setColumnCollapsed(6, true);
tbl.setColumnCollapsed(7, true);
// In portrait