【发布时间】:2013-09-08 17:55:21
【问题描述】:
我正在尝试将 ImageView 添加到 Java 中的 TableRow 中,但它始终显示为空白。图像似乎在那里,但它完全是白色的。
这是我的代码:
TableRow newRow = new TableRow(this);
newRow.setId(1);
LayoutParams lptr = new LayoutParams(
LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
newRow.setLayoutParams(lptr);
newRow.setBackgroundColor(this.getResources().getColor(R.color.white));
ImageView pImg = new ImageView(this);
pImg.setImageDrawable(this.getResources().getDrawable(R.drawable.error));
newRow.addView(pImg);
为什么它不起作用?
【问题讨论】:
-
您是否将新行添加到
TableLayout?
标签: android imageview drawable