title: Error on placing a URL on Picasso library on loading an image on an imageview in android
body: <p>I'm having an error on loading the image from the server and displaying it using the Picasso library, I have a JSON string and it has a field of <code>"img" =&gt; "whateverimageofanarticle.jpg"</code>, where in the value of that column on a JSON String may vary according to the content of the database. I can get the imagepath given by the JSON string, and display it on a textview but when I place it on the parameter of the <code>.load()</code> method in the Picasso Library, it does not work and stopped the execution of my app :( </p>
  
  <p>Anyway, I'm using fragments instead of library for easier and faster execution of the application (I don't know if fragments matters on my problem), also the code is in the <code>postExecute</code> method of the asynctask, where in the <code>onPostExecute()</code> was overriden. Here is my exact code and my whole code.</p>
  
  <pre><code>ImageView banner = new ImageView(getActivity().getApplicationContext());
  banner.getLayoutParams().height = 50;
  banner.getLayoutParams().width = 80;
  banner.requestLayout();
  
  Picasso.with(getActivity().getApplicationContext())
      .load("http://rtu-astronet.com/emag/"+_jsonObject.optString("img").toString())
      .into(banner);
  </code></pre>
  
  <p><strong>Whole code:</strong> </p>
  
  <pre><code>public class CollegeBulletinListFragment extends Fragment implements OnClickListener, Connector.OnPostExecuteListener{
      public CollegeBulletinListFragment(){
      }
  
      TextView kem;
      TextView headlinehead;
      TextView shortdesc;
      TextView headlinesender;
      LinearLayout llist;
      ImageButton img;
      ProgressBar pbColBul;
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
          View rootView = inflater.inflate(R.layout.fragment_collegebulletinlist, container, false);
          kem = (TextView) rootView.findViewById(R.id.mon_title);
          img = (ImageButton) rootView.findViewById(R.id.imageButton1);
          pbColBul = (ProgressBar) rootView.findViewById(R.id.pBcollegebul);
          img.setOnClickListener(this);
          headlinehead = (TextView) rootView.findViewById(R.id.mon_head_title);
          shortdesc = (TextView) rootView.findViewById(R.id.mon_head_desc);
          headlinesender = (TextView) rootView.findViewById(R.id.mon_head_sender);
          String c = getArguments().getString("passingWord");
          llist = (LinearLayout) rootView.findViewById(R.id.lllist);
          int colval = this.setTextAndColorsToHead(c);
          pbColBul.setVisibility(ProgressBar.VISIBLE);
          //Execute items on scroll view
          String secondFlag = "list";
          Connector connect= new Connector(getActivity().getApplicationContext(),colval,secondFlag,0,0,0,"","");
          connect.setOnPostExecuteListener(this);
          connect.execute("");
          return rootView;
      }
  
      public int setTextAndColorsToHead(String arg){
          int collegeval = 0;
          if (arg.equals("GN")){
              kem.setText("General News");
          } else if (arg.equals("CCS")){
              kem.setText("College of Computer Studies");
              collegeval = 1;
          } else if (arg.equals("COE")){
              kem.setText("College of Engineering");
              collegeval = 2;
          } else if (arg.equals("COED")){
              kem.setText("College of Education");
              collegeval = 4;
          } else if (arg.equals("CON")){
              kem.setText("College of Nursing");
              collegeval = 3;
          } else if (arg.equals("CBA")){
              kem.setText("College of Business and Accountancy");
              collegeval = 5;
          } else if (arg.equals("CAS")){
              kem.setText("College of Arts and Sciences");
              collegeval = 6;
          } else if (arg.equals("CIHM")){
              kem.setText("College of International and Hospitality Management");
              collegeval = 7;
          } 
          return collegeval;
      }
  
      @Override
      public void onClick(View arg0) {
          // TODO Auto-generated method stub
  
          SpecificArticleFragment spcf = new SpecificArticleFragment();
          Bundle args = new Bundle();
          String tag = arg0.getTag().toString();
          args.putString("art_id",tag);
          spcf.setArguments(args);
          FragmentManager fm = getFragmentManager();
          fm.beginTransaction().replace(R.id.content_frame, spcf).commit();
      }
  
      @Override
      public void onPostExecute(String result) {
          //headlinehead.setText(result);
          try{
              JSONObject jsonRootObj = new JSONObject(result);
              JSONArray jsonArray = jsonRootObj.optJSONArray("Data");
              JSONObject jsonObject = jsonArray.getJSONObject(0);
              //code for headline
              this.headlinehead.setText(jsonObject.optString("title").toString());
              this.shortdesc.setText(jsonObject.optString("shortdesc").toString());
              this.headlinesender.setText(jsonObject.optString("penname").toString());
              this.img.setTag(jsonObject.optString("id").toString());
              //code for headline
              for (int p = 1; p &lt; jsonArray.length(); p++){
                  JSONObject _jsonObject = jsonArray.getJSONObject(p);
                  LinearLayout conteach = new LinearLayout(getActivity().getApplicationContext());
                  LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
                  conteach.setLayoutParams(lp);
                  conteach.setOrientation(LinearLayout.VERTICAL);
  
                  ImageView banner = new ImageView(getActivity().getApplicationContext());
                  banner.getLayoutParams().height = 50;
                  banner.getLayoutParams().width = 80;
                  banner.requestLayout();
  
                  Picasso.with(getActivity().getApplicationContext())
                  .load("http://rtu-astronet.com/emag/"+_jsonObject.optString("img").toString())
                  .into(banner);
  
  
                  TextView art_title = new TextView(getActivity().getApplicationContext());
                  art_title.setText(_jsonObject.optString("title").toString());
                  art_title.setTextSize(20);
                  art_title.setLayoutParams(new LayoutParams(350,LayoutParams.WRAP_CONTENT));
  
                  TextView art_shortdesc = new TextView(getActivity().getApplicationContext());
                  art_shortdesc.setText(_jsonObject.optString("shortdesc").toString());
                  art_shortdesc.setTextSize(14);
                  art_shortdesc.setTypeface(null, Typeface.ITALIC);
                  art_shortdesc.setLayoutParams(new LayoutParams(350,LayoutParams.WRAP_CONTENT));
  
                  TextView art_sender = new TextView(getActivity().getApplicationContext());
                  art_sender.setText("Written by: " + _jsonObject.optString("sender").toString());
                  art_sender.setTextSize(14);
                  art_sender.setLayoutParams(new LayoutParams(350,LayoutParams.WRAP_CONTENT));
                  art_sender.setPadding(0, 0, 0, 15);
  
  
                  conteach.addView(art_title);
                  conteach.addView(art_shortdesc);
                  conteach.addView(art_sender);
                  conteach.setTag(_jsonObject.optString("id").toString());
                  conteach.setClickable(true);
                  conteach.setOnClickListener(new OnClickListener() {
                      public void onClick(View v) {
                          SpecificArticleFragment spcf = new SpecificArticleFragment();
                          Bundle args = new Bundle();
                          args.putString("art_id", v.getTag().toString());
                          spcf.setArguments(args);
  
                          FragmentManager ft = getFragmentManager();
                          ft.beginTransaction().replace(R.id.content_frame, spcf).commit();
                      }
                   });                
                  this.llist.addView(conteach);
  
              }
              this.pbColBul.setVisibility(ProgressBar.GONE);
          } catch(JSONException e){
  
          }
      }
  }
  </code></pre>