D disit11 Member Jul 10, 2012 #1 Hey everyone I have a quick question about changing an imagview image. But right now it will not work. I have a listview and it determines what is clicked by using the event below: Code: Copy Sub ListView1_ItemClick (Position As Int, Value As Object) If Value = "1" Then StartActivity(BulbAct) End If If Value = "2" Then StartActivity(BulbAct) End If End Sub I am using the same activity for each listview item with the same layout all I am wanting to do is change the image when one or the the other is clicked on. I will attach a sample project of what I tried and it did not work. It will not load the image for some reason. Attachments TestProj.zip TestProj.zip 11.5 KB · Views: 373
Hey everyone I have a quick question about changing an imagview image. But right now it will not work. I have a listview and it determines what is clicked by using the event below: Code: Copy Sub ListView1_ItemClick (Position As Int, Value As Object) If Value = "1" Then StartActivity(BulbAct) End If If Value = "2" Then StartActivity(BulbAct) End If End Sub I am using the same activity for each listview item with the same layout all I am wanting to do is change the image when one or the the other is clicked on. I will attach a sample project of what I tried and it did not work. It will not load the image for some reason.
klaus Expert Licensed User Longtime User Jul 10, 2012 #2 I think that you need to read some basics about how Android is working especialy how activities are working and the activity lifecycle. In your sample code the ImageView1 view is in activity test and not in the main activity. You must load the image in this activity and as ImageView1 is defined in the layout you must not initialize it. Attached a modified version. I'm estonished because you already aked almost the same question in another thread with the pseudo disit10 and there you got an example program but you never answered it!? Best regards. Attachments TestProj1.zip TestProj1.zip 11.6 KB · Views: 337 Upvote 0
I think that you need to read some basics about how Android is working especialy how activities are working and the activity lifecycle. In your sample code the ImageView1 view is in activity test and not in the main activity. You must load the image in this activity and as ImageView1 is defined in the layout you must not initialize it. Attached a modified version. I'm estonished because you already aked almost the same question in another thread with the pseudo disit10 and there you got an example program but you never answered it!? Best regards.
D disit11 Member Jul 10, 2012 #3 Yeah that is true I got it to work this way. I already had the code like this once before but what im stuck on is how do you get it to where the imageview will change when the other listview item is clicked? Upvote 0
Yeah that is true I got it to work this way. I already had the code like this once before but what im stuck on is how do you get it to where the imageview will change when the other listview item is clicked?
klaus Expert Licensed User Longtime User Jul 10, 2012 #4 Have a closer look at the code I posted in the other thread. The texts and the image file names are stored in process global variables these values remain as long as the application runs independent of what activity is active. Modified the previous test program with a process global variable. Best regards. Attachments TestProj1.zip TestProj1.zip 11.6 KB · Views: 368 Upvote 0
Have a closer look at the code I posted in the other thread. The texts and the image file names are stored in process global variables these values remain as long as the application runs independent of what activity is active. Modified the previous test program with a process global variable. Best regards.
D disit11 Member Jul 10, 2012 #5 Oh ok I see how its done. So your putting Image in the Process Globals so it can be accessed from all the activities? I am such a newb on this part. Sorry for all the newb questions I am just in the middle of transitioning from vb. Some of the stuff is different in this program. You are the greatest :sign0060: Upvote 0
Oh ok I see how its done. So your putting Image in the Process Globals so it can be accessed from all the activities? I am such a newb on this part. Sorry for all the newb questions I am just in the middle of transitioning from vb. Some of the stuff is different in this program. You are the greatest :sign0060:
klaus Expert Licensed User Longtime User Jul 10, 2012 #6 So your putting Image in the Process Globals so it can be accessed from all the activities? Click to expand... Yes, that's what process global variables are made for. Did you have a look at the Beginner's Guide ? Best regards. Upvote 0
So your putting Image in the Process Globals so it can be accessed from all the activities? Click to expand... Yes, that's what process global variables are made for. Did you have a look at the Beginner's Guide ? Best regards.
D disit11 Member Jul 10, 2012 #7 I have skimmed through it. I have not done a whole bunch of reading through it. But I def will tonight. Upvote 0
I have skimmed through it. I have not done a whole bunch of reading through it. But I def will tonight.