安卓在TableLayout中使用动态创建TextView,界面不显示,是为什么?
intnumber=numberListener.getSelect();floattime=timeListener.getTime();System.out.prin...
int number = numberListener.getSelect();
float time = timeListener.getTime();
System.out.println("选择的数的组数为"+number+".时间间隔为"+time);
tableLayout = new TableLayout(NumberTrainActivity.this);
int row = number/5;
tableLayout.setStretchAllColumns(true);
for (int i = 0; i < row; i++) {
TableRow tableRow = new TableRow(NumberTrainActivity.this);
for (int j = 0; j < 5; j++) {
TextView tv = new TextView(NumberTrainActivity.this);
tv.setText("你好");
// tv.setTextSize(20);
tableRow.addView(tv);
System.out.println("--------------");
}
tableLayout.addView(tableRow);
System.out.println("**************");
}
System打印出来的东西正常,也没有报错 展开
float time = timeListener.getTime();
System.out.println("选择的数的组数为"+number+".时间间隔为"+time);
tableLayout = new TableLayout(NumberTrainActivity.this);
int row = number/5;
tableLayout.setStretchAllColumns(true);
for (int i = 0; i < row; i++) {
TableRow tableRow = new TableRow(NumberTrainActivity.this);
for (int j = 0; j < 5; j++) {
TextView tv = new TextView(NumberTrainActivity.this);
tv.setText("你好");
// tv.setTextSize(20);
tableRow.addView(tv);
System.out.println("--------------");
}
tableLayout.addView(tableRow);
System.out.println("**************");
}
System打印出来的东西正常,也没有报错 展开
- 你的回答被采纳后将获得:
- 系统奖励15(财富值+成长值)+难题奖励30(财富值+成长值)
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询