Android: Using Picasso to load multiple images from a string of URLS in Recycler View












0















I think I understand what's happening here, it's loading the first URL into the recyler view and looping it through and loading the other 2 URLs, but not placing them into the correct place in the RecyclerView. It works, but only for the first image. How can I tell it to place a new image in each. Please not the "Picasso.with(context) is deprecated" and "get()" I cannot pass in context or integers. `



class MainAdapter extends RecyclerView.Adapter<MainAdapter.ViewHolder>   {
private ArrayList<Webtoon> mWebtoon;
private Context context;
RecyclerView mRecyclerView;
RecyclerView.Adapter mAdapter;
private ArrayList<Webtoon> mWebtoons;
String imageUrl = {"https://shared-comic.pstatic.net/thumb/webtoon/183559/thumbnail/title_thumbnail_20160516123017_t218x120.jpg",
"https://shared-comic.pstatic.net/thumb/webtoon/183559/thumbnail/title_thumbnail_20160516123017_t218x120.jpg",
"https://shared-comic.pstatic.net/thumb/webtoon/557672/thumbnail/title_thumbnail_20150323145400_t220x202.jpg"};
public MainAdapter(ArrayList<Webtoon> webtoons) {
mWebtoons = webtoons;
}

@Override
public MainAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.row, parent, false);
return new ViewHolder(view);
}


@Override
public void onBindViewHolder(MainAdapter.ViewHolder holder, int position) {

String title1 =(mWebtoons.get(position).getmUrl().replaceAll(":: 네이버 만화", ""));
String title2 = title1.replaceAll(":: 네이버 웹툰", "");
holder.mTitleTextView.setText(title2);


for (int i = 0; i < imageUrl.length; i++) {


Picasso.get().load
(imageUrl[i]).resize(500,400)
.into(holder.webtoonCoverImage);

}


}

@Override
public int getItemCount() {
return mWebtoons.size();
}

public class ViewHolder extends RecyclerView.ViewHolder {

public TextView mTitleTextView;
public ImageView webtoonCoverImage;

public ViewHolder(View itemView) {
super(itemView);

mTitleTextView = (TextView) itemView.findViewById(R.id.title_text_view);
webtoonCoverImage = itemView.findViewById(R.id.webtoon_cover_image);

}
}


}










share|improve this question



























    0















    I think I understand what's happening here, it's loading the first URL into the recyler view and looping it through and loading the other 2 URLs, but not placing them into the correct place in the RecyclerView. It works, but only for the first image. How can I tell it to place a new image in each. Please not the "Picasso.with(context) is deprecated" and "get()" I cannot pass in context or integers. `



    class MainAdapter extends RecyclerView.Adapter<MainAdapter.ViewHolder>   {
    private ArrayList<Webtoon> mWebtoon;
    private Context context;
    RecyclerView mRecyclerView;
    RecyclerView.Adapter mAdapter;
    private ArrayList<Webtoon> mWebtoons;
    String imageUrl = {"https://shared-comic.pstatic.net/thumb/webtoon/183559/thumbnail/title_thumbnail_20160516123017_t218x120.jpg",
    "https://shared-comic.pstatic.net/thumb/webtoon/183559/thumbnail/title_thumbnail_20160516123017_t218x120.jpg",
    "https://shared-comic.pstatic.net/thumb/webtoon/557672/thumbnail/title_thumbnail_20150323145400_t220x202.jpg"};
    public MainAdapter(ArrayList<Webtoon> webtoons) {
    mWebtoons = webtoons;
    }

    @Override
    public MainAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.row, parent, false);
    return new ViewHolder(view);
    }


    @Override
    public void onBindViewHolder(MainAdapter.ViewHolder holder, int position) {

    String title1 =(mWebtoons.get(position).getmUrl().replaceAll(":: 네이버 만화", ""));
    String title2 = title1.replaceAll(":: 네이버 웹툰", "");
    holder.mTitleTextView.setText(title2);


    for (int i = 0; i < imageUrl.length; i++) {


    Picasso.get().load
    (imageUrl[i]).resize(500,400)
    .into(holder.webtoonCoverImage);

    }


    }

    @Override
    public int getItemCount() {
    return mWebtoons.size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder {

    public TextView mTitleTextView;
    public ImageView webtoonCoverImage;

    public ViewHolder(View itemView) {
    super(itemView);

    mTitleTextView = (TextView) itemView.findViewById(R.id.title_text_view);
    webtoonCoverImage = itemView.findViewById(R.id.webtoon_cover_image);

    }
    }


    }










    share|improve this question

























      0












      0








      0








      I think I understand what's happening here, it's loading the first URL into the recyler view and looping it through and loading the other 2 URLs, but not placing them into the correct place in the RecyclerView. It works, but only for the first image. How can I tell it to place a new image in each. Please not the "Picasso.with(context) is deprecated" and "get()" I cannot pass in context or integers. `



      class MainAdapter extends RecyclerView.Adapter<MainAdapter.ViewHolder>   {
      private ArrayList<Webtoon> mWebtoon;
      private Context context;
      RecyclerView mRecyclerView;
      RecyclerView.Adapter mAdapter;
      private ArrayList<Webtoon> mWebtoons;
      String imageUrl = {"https://shared-comic.pstatic.net/thumb/webtoon/183559/thumbnail/title_thumbnail_20160516123017_t218x120.jpg",
      "https://shared-comic.pstatic.net/thumb/webtoon/183559/thumbnail/title_thumbnail_20160516123017_t218x120.jpg",
      "https://shared-comic.pstatic.net/thumb/webtoon/557672/thumbnail/title_thumbnail_20150323145400_t220x202.jpg"};
      public MainAdapter(ArrayList<Webtoon> webtoons) {
      mWebtoons = webtoons;
      }

      @Override
      public MainAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
      View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.row, parent, false);
      return new ViewHolder(view);
      }


      @Override
      public void onBindViewHolder(MainAdapter.ViewHolder holder, int position) {

      String title1 =(mWebtoons.get(position).getmUrl().replaceAll(":: 네이버 만화", ""));
      String title2 = title1.replaceAll(":: 네이버 웹툰", "");
      holder.mTitleTextView.setText(title2);


      for (int i = 0; i < imageUrl.length; i++) {


      Picasso.get().load
      (imageUrl[i]).resize(500,400)
      .into(holder.webtoonCoverImage);

      }


      }

      @Override
      public int getItemCount() {
      return mWebtoons.size();
      }

      public class ViewHolder extends RecyclerView.ViewHolder {

      public TextView mTitleTextView;
      public ImageView webtoonCoverImage;

      public ViewHolder(View itemView) {
      super(itemView);

      mTitleTextView = (TextView) itemView.findViewById(R.id.title_text_view);
      webtoonCoverImage = itemView.findViewById(R.id.webtoon_cover_image);

      }
      }


      }










      share|improve this question














      I think I understand what's happening here, it's loading the first URL into the recyler view and looping it through and loading the other 2 URLs, but not placing them into the correct place in the RecyclerView. It works, but only for the first image. How can I tell it to place a new image in each. Please not the "Picasso.with(context) is deprecated" and "get()" I cannot pass in context or integers. `



      class MainAdapter extends RecyclerView.Adapter<MainAdapter.ViewHolder>   {
      private ArrayList<Webtoon> mWebtoon;
      private Context context;
      RecyclerView mRecyclerView;
      RecyclerView.Adapter mAdapter;
      private ArrayList<Webtoon> mWebtoons;
      String imageUrl = {"https://shared-comic.pstatic.net/thumb/webtoon/183559/thumbnail/title_thumbnail_20160516123017_t218x120.jpg",
      "https://shared-comic.pstatic.net/thumb/webtoon/183559/thumbnail/title_thumbnail_20160516123017_t218x120.jpg",
      "https://shared-comic.pstatic.net/thumb/webtoon/557672/thumbnail/title_thumbnail_20150323145400_t220x202.jpg"};
      public MainAdapter(ArrayList<Webtoon> webtoons) {
      mWebtoons = webtoons;
      }

      @Override
      public MainAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
      View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.row, parent, false);
      return new ViewHolder(view);
      }


      @Override
      public void onBindViewHolder(MainAdapter.ViewHolder holder, int position) {

      String title1 =(mWebtoons.get(position).getmUrl().replaceAll(":: 네이버 만화", ""));
      String title2 = title1.replaceAll(":: 네이버 웹툰", "");
      holder.mTitleTextView.setText(title2);


      for (int i = 0; i < imageUrl.length; i++) {


      Picasso.get().load
      (imageUrl[i]).resize(500,400)
      .into(holder.webtoonCoverImage);

      }


      }

      @Override
      public int getItemCount() {
      return mWebtoons.size();
      }

      public class ViewHolder extends RecyclerView.ViewHolder {

      public TextView mTitleTextView;
      public ImageView webtoonCoverImage;

      public ViewHolder(View itemView) {
      super(itemView);

      mTitleTextView = (TextView) itemView.findViewById(R.id.title_text_view);
      webtoonCoverImage = itemView.findViewById(R.id.webtoon_cover_image);

      }
      }


      }







      android image android-recyclerview picasso






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 19 '18 at 13:34









      Race ReedRace Reed

      14




      14
























          0






          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53375796%2fandroid-using-picasso-to-load-multiple-images-from-a-string-of-urls-in-recycler%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53375796%2fandroid-using-picasso-to-load-multiple-images-from-a-string-of-urls-in-recycler%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          How to pass form data using jquery Ajax to insert data in database?

          National Museum of Racing and Hall of Fame

          Guess what letter conforming each word