[英]How can I transfer data new intent
my Onbindview holder
我的 Onbindview 支架
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.
此数据已在 mysql 中注册,我正在从目录中提取并进行改造。
New display新显示器
您可以将图像作为字符串从屏幕 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.在不了解您为何尝试在活动之间通过 IPC 发送光栅图像的更多信息的情况下,我认为我能给您的最佳建议是不要尝试这样做。
Instead, simply send the URL in the intent and have Activity 2 use glide to load and display the image.相反,只需发送意图中的 URL 并让 Activity 2 使用 glide 加载和显示图像。
The batter way is to pass full URL in intent as String and receive it on another Activity.击球手的方法是将意图中的完整 URL 作为字符串传递并在另一个 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);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.