简体   繁体   English

通过意图将图像网址传递给另一个活动

[英]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. 我是android的新手,我正在使用Picasso从本地主机接收图像。我想通过意图将图像传递给另一个新活动,但是我无法在布局中显示图像。帮助我解决这个问题。

This is my Movie.class 这是我的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 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 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 尝试使用此代码,看看您在strImage中有什么内容,然后在此处粘贴评论

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(); 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. 尝试着重于双引号内的元素。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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