我正在尝试向LinearLayout添加一堆视图。
for (Business b : businesses) {
View view = getLayoutInflater().inflate(R.layout.card_item, mLinearLayout, true);
ImageView mImageView = (ImageView) view.findViewById(R.id.image);
Picasso.with(getBaseContext())
.load(b.getPhotoUrl())
.into(mImageView);
TextView mTextView = (TextView) view.findViewById(R.id.title);
mTextView.setText(b.getName());
}
然而,它显示1张信息卡。然后是19个空白视图。
答案 0 :(得分:1)
for (Business b : businesses) {
View view = getLayoutInflater().inflate(R.layout.card_item, mLinearLayout, false);
ImageView mImageView = (ImageView) view.findViewById(R.id.image);
Picasso.with(getBaseContext())
.load(b.getPhotoUrl())
.into(mImageView);
TextView mTextView = (TextView) view.findViewById(R.id.title);
mTextView.setText(b.getName());
mLinearLayout.addView(view);
}