title: How do I change the viewmodel observable data in android?
body: <p>I created a gridView that has an ArrayAdapter, the gridView contains only photos, I am fetching the image url in an Array and I am observing the array through my activity. Here is my viewmodel</p>
  
  <pre><code>class ProfileViewModel constructor(): ViewModel() {
      var first_name: String? = null
      var last_name: String? = null
      var dob: String? = null
      var address: String? = null
      var organization: String? = null
      var hobby: String? = null
      var bio: String? = null
      var imagePath: String = ""
  
      private val imageList : MutableLiveData&lt;ArrayList&lt;ProfileViewModel&gt;&gt; = MutableLiveData()
  
      constructor(photo : Photo) : this() {
          this.imagePath = photo.imageUrl
      }
  
      fun getImageUrl() : String {
          return imagePath
      }
  
      companion object {
          @BindingAdapter("imageUrl")
          @JvmStatic
          fun loadImage(imageView: ImageView, imageUrl: String) {
              Glide.with(imageView.context)
                  .load(imageUrl)
                  .apply(RequestOptions.centerCropTransform())
                  .placeholder(R.drawable.ic_add_icon)
                  .into(imageView)
          }
      }
  
      val profileViewModels : MutableLiveData&lt;ArrayList&lt;ProfileViewModel&gt;&gt;
          get() {
              val profileViewModels = ArrayList&lt;ProfileViewModel&gt;()
  
              val photo1 = Photo("")
              val profileVM = ProfileViewModel(photo1)
              repeat(6) {
                  profileViewModels.add(profileVM)
              }
  
              imageList.value = profileViewModels
              return imageList
          }
      }
  }
  </code></pre>
  
  <p>Here is my activity where I am observing the data</p>
  
  <pre><code>override fun onCreate(savedInstanceState: Bundle?) {
          super.onCreate(savedInstanceState)
  
          val binding: ActivityProfileBinding =
              DataBindingUtil.setContentView(this, R.layout.activity_profile)
  
          val viewModel = ViewModelProvider(this).get(ProfileViewModel::class.java)
  
          viewModel.profileViewModels.observe(this,
              Observer&lt;ArrayList&lt;ProfileViewModel&gt;&gt; { image_paths -&gt;
                  Log.d("added", "$image_paths")
                  val imageAdapter = ImageAdapter(this@Profile, R.layout.image_card, image_paths!!)
                  gridView.adapter = imageAdapter
              })
  }
  </code></pre>
  
  <p>I am getting images in the gridView but I want to update the observable value on gridView Item click in the clicked position. How do I do that?</p>