Changing ImageView Image?

disit11

Member
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:

B4X:
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
    11.5 KB · Views: 158

klaus

Expert
Licensed User
Longtime User
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
    11.6 KB · Views: 154
Upvote 0

disit11

Member
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

klaus

Expert
Licensed User
Longtime User
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
    11.6 KB · Views: 171
Upvote 0

disit11

Member
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
Top