我试图用Picasso实现水平滚动视图以进行延迟加载。 ImageView添加到Scrollview但图像未加载。
请帮助!!
我的代码是
private void populateImages(Picasso picasso) {
String imageURL = "URL";
String[] imageArray = new String[] {"category_accomodation_1","category_gadget_1","categpory_essential_services_1","category_home_1"};
myGallery = (LinearLayout)findViewById(R.id.gallerylayout);
for(int i = 0 ;i<imageArray.length;i++){
myGallery.addView(insertPhoto(imageURL+imageArray[i]));
}
public View insertPhoto(String path){
LinearLayout layout = new LinearLayout(getApplicationContext());
layout.setGravity(Gravity.CENTER);
ImageView imageView = new ImageView(getApplicationContext());
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
Picasso.with(this).load(path).placeholder(R.drawable.load).into(imageView);
layout.addView(imageView);
return layout;
}
我的xml是
<HorizontalScrollView
android:id="@+id/imagescrollview"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_toLeftOf="@+id/uploadphoto"
android:layout_below="@+id/recommend">
<LinearLayout android:id="@+id/gallerylayout"
android:layout_width="wrap_content"
android:baselineAligned="false"
android:orientation="horizontal"
android:layout_height="50dp">
</LinearLayout>
</HorizontalScrollView>
答案 0 :(得分:1)
您是否更改了图像的路径是否正确?看起来它会加载类似http://www.example.com/category_accomodation_1的内容,它看起来不像我的有效图片网址。