我尝试使用Picasso填充一系列ImageView - 但由于某种原因 - 只填充了第一张图片。谁能说出为什么会发生这种情况?我已经多次看了这个,我似乎无法在这个for循环中发现这个问题:
09-26 23:10:58.445: I/System.out(14978): WTF :https://i.ytimg.com/vi/oSYctdFjFSw/default.jpg
09-26 23:10:58.456: I/System.out(14978): WTF : https://i.ytimg.com/vi/DyFE4IEjX4I/default.jpg
09-26 23:10:58.466: I/System.out(14978): WTF : https://i.ytimg.com/vi/6XCU_Wv0ekA/default.jpg
09-26 23:10:58.475: I/System.out(14978): WTF : https://i.ytimg.com/vi/5U1ndFiYLh4/default.jpg
09-26 23:10:58.483: I/System.out(14978): WTF : https://i.ytimg.com/vi/6gLscCEiSXE/default.jpg
ImageView imageItem1;
for (int i = 0; i < 3; ++i) {
// Create new ImageView
imageItem1 = new ImageView(this);
// Set the shadow background
imageItem1.setBackgroundResource(R.drawable.shadow);
String[] separated = result.toString().replace("[", "").replace("]", "").split(",");
String scrubbedURL = separated[j].toString();
Picasso.with(this).load(scrubbedURL).into(imageItem1);
System.out.println("WTF :" + scrubbedURL);
// Set the size of the image view to the previously computed value
imageItem1.setLayoutParams(new LinearLayout.LayoutParams(
imageWidth, imageWidth));
// / Add image view to the carousel container
mCarouselContainer1.addView(imageItem1);
++j;
}
我们非常感谢任何建议/评论/见解......我很难过。
答案 0 :(得分:0)
尝试:
ImageView imageItem1;
String[] separated = result.toString().replace("[", "").replace("]", "").split(",");
for (int i = 0; i < 3; ++i) {
// Create new ImageView
imageItem1 = new ImageView(this);
// Set the shadow background
imageItem1.setBackgroundResource(R.drawable.shadow);
String scrubbedURL = separated[j].trim();
...
++j;
}