簡體   English   中英

通過意圖將圖像網址傳遞給另一個活動

[英]Pass Image url through intent to a another activity

我是android的新手,我正在使用Picasso從本地主機接收圖像。我想通過意圖將圖像傳遞給另一個新活動,但是我無法在布局中顯示圖像。幫助我解決這個問題。

這是我的Movie.class

公共課電影{

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);

嘗試使用此代碼,看看您在strImage中有什么內容,然后在此處粘貼評論

更新:

 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);

嘗試着重於雙引號內的元素。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM