【发布时间】:2020-08-29 12:12:28
【问题描述】:
我动态创建了一个表格布局。 现在,如果屏幕是横向或纵向,我想更改特定列的可见性。 我的代码可以做到这一点吗?
感谢您的帮助。
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);
}
用于定位的 if 运算符
int orientation = getResources().getConfiguration().orientation;
if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
// In landscape
} else {
// In portrait
}
【问题讨论】:
标签: java android tablelayout