作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我当前的代码是:
for(int i=0;i<jArray.length();i++){
JSONObject json_data = jArray.getJSONObject(i);
String b = json_data.getString("examnames");
JSONObject getexamnamesobject = new JSONObject(b);
getexamnames=getexamnamesobject.getString("types");
TableRow tr = new TableRow(this);
TextView tv1 = new TextView(this);
createView(tr,tv1,getexamnames);
t1.addView(tr);
}
public void createView(TableRow tr, TextView t, String viewdata) {
t.setText(viewdata);
//adjust the porperties of the textView
t.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));
//t.setTextColor(Color.DKGRAY);
//t.setBackgroundColor(Color.CYAN);
t.setPadding(20, 0, 0, 0);
tr.setPadding(0, 1, 0, 1);
//tr.setBackgroundColor(Color.BLACK);
tr.addView(t); // add TextView to row.
}
上面代码的输出是,我像这样垂直获取 TextView :
English
Maths
Science
为了得到这样的水平输出,上面的代码必须改变什么:
English Maths Science
请帮帮我。这对我来说很重要提前致谢
最佳答案
将 setStretchAllColumns() 和 setShrinkAllColumns() 设置为表格布局。并将其设置为表格布局的“水平”方向。
关于java - 如何在android中创建动态水平表格行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9030196/
我是一名优秀的程序员,十分优秀!