[英]Set ImageView Resource and TextView Text from Another Activity
I have a list view in an activity and when a row is selected I want to show another activity that contains an ImageView and a TextView. 我在一个活动中有一个列表视图,当选择一行时,我想显示另一个包含ImageView和TextView的活动。 How can I set the image and text from the first activity?
如何在第一个活动中设置图像和文本? I'm guessing for the text I can use an extra with the intent.
我猜想我可以在文字上加上一些文字。
intent.putExtra("data", bitmap)
intent.putExtra("your_string", strName);
You can recieve bitmap from another activity like this 您可以像这样从其他活动中接收位图
Intent intent = getIntent();
Bitmap bitmap = (Bitmap) intent.getParcelableExtra("data");
It costs a lot of memory and is also slow. 它占用大量内存,而且速度很慢。
If you want to pass it inbetween activities, you can store it in a file. 如果要在活动之间传递它,可以将其存储在文件中。 That's more efficient.
这样更有效。
There are multiple ways to sending data between Activities 活动之间有多种发送数据的方法
intent.putExtra("data", bitmap)
and recieve it as @deniz suggested intent.putExtra("data", bitmap)
并按照@deniz的建议进行接收
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.