简体   繁体   中英

Pass Image url through intent to a another activity

I'm new to android and I am using Picasso to receive image from my localhost.I want to pass image via intent to another new activity but I'm unable to display the image in my layout.Help me to figure out this problem.

This is my Movie.class

public class Movie {

private String Sno;
private String Name;
private String Director;
private String Image;

public String getSno() {
    return Sno;
}

public void setSno(String sno) {
    Sno = sno;
}

public String getName() {
    return Name;
}

public void setName(String name) {
    Name = name;
}

public String getDirector() {
    return Director;
}

public void setDirector(String director) {
    Director = director;
}

public String getImage() {
    return Image;
}

public void setImage(String image) {
    Image = image;
}

}

MyFragment.class

    public void onClick(View v, int position, boolean isLongClick) {
    String Sno =movieList.get(position).getSno().toString();
    String Name = movieList.get(position).getName().toString();
    String strDirector =         movieList.get(position).getDirector().toString();
    String strImage = movieList.get(position).getImage().toString();

    Intent intent = new Intent(getActivity(),Movie_detail.class);
    intent.putExtra("Sno",Sno);
    intent.putExtra("Director",strDirector);
    intent.putExtra("Name",Name);
    intent.putExtra("Image",strImage);

    startActivity(intent);
    }

Movie_detail.class

    Intent intent= getIntent();
    ImageView imageView = (ImageView) findViewById(R.id.imageView);
    strImage= String.valueOf(intent.getStringExtra("strImage"));

    Picasso.with(this)
            .load(strImage)
            .into(imageView);

Try to use this code and see what do you have in strImage and paste here in comment

Updated:

 Intent intent= getIntent();
        ImageView imageView = (ImageView) findViewById(R.id.imageView);
        strImage= String.valueOf(intent.getStringExtra("Image"));
        Log.d("LOG_TAG" strImage);
        Picasso.with(this)
                .load(strImage)
                .into(imageView);

Intent intent= getIntent();

    ImageView imageView = (ImageView) findViewById(R.id.imageView);

    strImage= String.valueOf(intent.getStringExtra("Image"));

    Log.d("LOG_TAG" strImage);
    Picasso.with(this)
            .load(strImage)
            .into(imageView);

try to focus on elements which is inside double quotes.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM