1

I'm trying to implement a horizontal scrollview with Picasso for lazyloading . ImageView adding to the Scrollview but image is not loading.

Please Help !!

My code is

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;
}

my xml is

       <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>
TMH
  • 6,096
  • 7
  • 51
  • 88
Pavan
  • 519
  • 1
  • 6
  • 16
  • Have you changed the path is correct to the images? It looks like it will be loading something like `http://www.example.com/category_accomodation_1` which doesn't look like a valid image URL to me. – TMH Apr 10 '14 at 13:58
  • @TomHart : My bad .. It was the mistake of url. Thank u for pointing this out. – Pavan Apr 11 '14 at 07:00
  • Not a problem, sometimes the simplest errors are the hardest to fix. If I post that as an answer can you accept it so others can see what the problem was? – TMH Apr 11 '14 at 08:29

1 Answers1

1

Have you changed the path is correct to the images? It looks like it will be loading something like http://www.example.com/category_accomodation_1 which doesn't look like a valid image URL to me.

TMH
  • 6,096
  • 7
  • 51
  • 88