1. Download the free trial version

Changing ImageView Image?

Discussion in 'Questions' started by disit11, Jul 10, 2012.

  1. disit11

    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:

    Code:
    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.
     

    Attached Files:

  2. klaus

    klaus Expert Licensed 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.
     

    Attached Files:

  3. disit11

    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?
     
  4. klaus

    klaus Expert Licensed 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.
     

    Attached Files:

  5. disit11

    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:
     
  6. klaus

    klaus Expert Licensed User

    Yes, that's what process global variables are made for.

    Did you have a look at the Beginner's Guide ?

    Best regards.
     
  7. disit11

    disit11 Member

    I have skimmed through it. I have not done a whole bunch of reading through it. But I def will tonight.
     

Share This Page

Loading...