简体   繁体   中英

How can I transfer data new intent

my Onbindview holder

    Glide.with(holder.t1.getContext())
            .load("http://example/example/images/" +data.get(position).getImage()).into(holder.img);
}

And my interface

itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (iOtobusSaatleriInterface != null){
                    int position = getAdapterPosition();
                    if (position != RecyclerView.NO_POSITION);
                    iOtobusSaatleriInterface.onItemClick(position);
                    Intent intent = new Intent(context,deneme.class);
                    intent.putExtra("name",data.get(position).getName());
                    intent.putExtra("resim", String.valueOf(Glide.with(itemView)
                            .load("http://example/example/images/")));
                    
                    context.startActivity(intent);
                }
            }
        });

my new activity

Intent intent = getIntent();
    String name = intent.getStringExtra("name");
    int goruntu = intent.getIntExtra("resim",0);
    imageView.setImageResource(goruntu);
    textView.setText(name);

finally my photo is not coming. I just can't get the image data in the new activity. This data is registered in mysql and I am pulling from the directory with retrofit.

New display

my imageview display

And my xml

您可以将图像作为字符串从屏幕 A 传递到屏幕 B。

Without knowing more about why you are trying to send a raster image over IPC between activities, I think the best advice I can give you is to not try to do that.

Instead, simply send the URL in the intent and have Activity 2 use glide to load and display the image.

The batter way is to pass full URL in intent as String and receive it on another Activity.

Intent intent = new Intent(context,deneme.class);
                    intent.putExtra("name",data.get(position).getName());
                    intent.putExtra("resim","YOUR_FULL_URL");

At Another Activity

    Intent intent = getIntent();
        String name = intent.getStringExtra("name");
        String goruntu = intent.getStringExtra("resim");
    
String.valueOf(Glide.with(imageView)
                            .load(goruntu)
        textView.setText(name);

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