title: Getting and Passing Image URL with Picasso
body: <p>I am trying to get the image URL from the selected image that the user selects so that I can then pass that string/URL to another Fragment that I have set up so that the image can be viewed fully via an image view.</p>
  
  <p>How would I be able to achieve this? thanks.</p>
  
  <p>Here is the SampleGridViewAdapter class:</p>
  
  <pre><code>inal class SampleGridViewAdapter extends BaseAdapter {
  private final Context context;
  public final List&lt;String&gt; urls = new ArrayList&lt;String&gt;();
  
  public SampleGridViewAdapter(Context context) {
      this.context = context;
  
      // Ensure we get a different ordering of images on each run.
      Collections.addAll(urls, Data.URLS);
      Collections.shuffle(urls);
  
  
  
  }
  
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
      SquaredImageView view = (SquaredImageView) convertView;
      if (view == null) {
          view = new SquaredImageView(context);
          view.setScaleType(CENTER_CROP);
      }
  
      // Get the image URL for the current position.
      String url = getItem(position);
  
      // Trigger the download of the URL asynchronously into the image view.
      Picasso.with(context) //
              .load(url) //
              .placeholder(R.drawable.placeholder) //
              .error(R.drawable.error) //
              .fit() //
              .into(view);
  
      return view;
  }
  
  @Override
  public int getCount() {
      return urls.size();
  }
  
  @Override
  public String getItem(int position) {
      return urls.get(position);
  }
  
  @Override
  public long getItemId(int position) {
      return position;
  }
  }
  </code></pre>
  
  <p>Here is my SampleGridViewActivity:</p>
  
  <pre><code>public class SampleGridViewActivity extends SherlockFragment {
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
          Bundle savedInstanceState) {
      View view = inflater.inflate(R.layout.sample_gridview_activity,
              container, false);
  
      GridView Grid = (GridView) view.findViewById(R.id.grid_view);
      Grid.setAdapter(new SampleGridViewAdapter(getActivity()));
  
      Grid.setOnItemClickListener(new OnItemClickListener() {
  
          @Override
          public void onItemClick(AdapterView&lt;?&gt; parent, View view,
                  int position, long urls) {
              // TODO Auto-generated method stub
  
              FragmentManager fm = getFragmentManager();
              FragmentTransaction transaction = fm.beginTransaction();
  
              Fragment openImage = new ImageViewPager();
  
              transaction.replace(R.id.content_frame, openImage);
  
              transaction.addToBackStack(null);
  
              transaction.commit();
  
          }
      });
  
      return view;
  
  }
  
   }
  </code></pre>
  
  <p>Here is the class I would like to send the string to:</p>
  
  <pre><code>public class ImageViewer extends SherlockFragment {
  
  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
          Bundle savedInstanceState) {
      View view = inflater.inflate(R.layout.imageviewpager, container, false);
  
      ImageView IMGView = (ImageView) view.findViewById(R.id.imageView1);
  
      Picasso.with(getActivity()).load("Pass URL into HERE").into(IMGView);
  
      return view;
  }
  
  }
  </code></pre>