我想创建一个包含行和列以及内部图像的表。返回该布局的方法是:
public LinearLayout getLayout(int rows, int columns, Drawable img, Context ctx) {
Bitmap bitmap = ((BitmapDrawable)img).getBitmap();
Drawable d = new BitmapDrawable(resize(bitmap, 15, 15));
LinearLayout.LayoutParams paramsCard = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
paramsCard.setMargins(5, 5, 5, 5);
LinearLayout.LayoutParams paramsRow = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
LinearLayout.LayoutParams paramsTable = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
LinearLayout lyTable = new LinearLayout(ctx);
lyTable.setLayoutParams(paramsTable);
lyTable.setOrientation(LinearLayout.VERTICAL);
for(int i = 0; i < rows; i++){
LinearLayout lyRow = new LinearLayout(ctx);
lyRow.setOrientation(LinearLayout.HORIZONTAL);
lyRow.setLayoutParams(paramsRow);
for(int j = 0; j < columns; j++){
View viewCard = new View(ctx);
viewCard.setLayoutParams(paramsCard);
viewCard.setBackgroundDrawable(d);
lyRow.addView(viewCard);
}
lyTable.addView(lyRow);
}
return lyTable;
}
为什么我只能获得一张图片?