onClickListener on imageview to start new intent(imageview 上的 onClickListener 开始新的意图)
问题描述
所以我尝试使用 onClickListener 将图像从一个活动传递到一个新活动,但我不知道该怎么做.它的工作原理是应用程序从一个列表视图开始,您可以在其中选择一个项目,然后它会打开一个新活动,显示一些信息和下面的图像.我希望能够单击图像以在新活动中将其打开.
So Im trying to use an onClickListener to pass an image from one activity to a new activity but I cannot figure out how to do it. How it works is the app starts with a listview where you can select an item and it opens a new activity that displays some information and an image below. I want to be able to click the image to open it in a new activity.
这是我的 routeDetails.java,这是我要单击的图像所在的位置
Heres my routeDetails.java this is where the image I want to click is located
还有附带的activity_route_details.xml
and heres the activity_route_details.xml that goes with it
这是我希望在其中打开图像的 FullScreenImage.java
heres my FullScreenImage.java that I want the image to open in
这里有 full_scren_image.xml 来配合它
And heres the full_scren_image.xml to go with it
推荐答案
将您的图像用作 ByteArray.这对我有用,没有任何问题.在发送者活动的点击侦听器中执行以下操作,
Use your image as ByteArray. This worked for me without any problem. In your click listener of the sender activity do the following,
并在您的接收器活动中执行以下操作.
And in your receiver activity do the following.
在接收器活动的 oncreate 方法中调用 getImage().上下文是您的应用程序上下文.祝你好运:)
call getImage() in your oncreate method of your receiver activity. The context is your application context. Good luck:)
这篇关于imageview 上的 onClickListener 开始新的意图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!