在下面的java文件中,我声明了一个imageview和TextView。
int numRow = 6;
int numCol = 4;
TableLayout tblLayout = (TableLayout)findViewById(R.id.tblLayout);
for(int i = 0; i < numRow; i++) {
HorizontalScrollView HSV = new HorizontalScrollView(this);
HSV.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
TableRow tblRow = new TableRow(this);
tblRow.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
tblRow.setBackgroundResource(R.drawable.bookshelf);
// tblRow.setGravity(Gravity.CENTER | Gravity.BOTTOM);
for(int j = 0; j < numCol; j++) {
ImageView imageView = new ImageView(this);
imageView.setImageResource(R.drawable.icon);
imageView.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
TextView textView = new TextView(this);
textView.setText("Java Tester");
textView.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
// textView.setTextColor(Color.parseColor("#FFFFFF"));
//Sultan
tblRow.addView(imageView,j);
// tblRow.addView(textView,j);
}
HSV.addView(tblRow);
tblLayout.addView(HSV, i);
但是文本视图的文本没有显示在屏幕上。问题是什么 ?
我想在TextView下面显示文本“Java Tester”。我能为此目的做些什么?