-1

my image View id is showing an error, probably not importing... this is my xml for Image View...

<ImageView
        android:id="@+id/abc"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintHorizontal_bias="1.0"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="1.0"
        tools:srcCompat="@tools:sample/avatars"
        android:contentDescription="TODO" />

and this is MainActivity where in glide, image view id is not accepting...

val jsonObjectRequest =  JsonObjectRequest(
            Request.Method.GET, url, null,
            {response ->
                Glide.with(this).load(url).into(abc);
            },
            { })

these are my imports...

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.android.volley.Request
import com.android.volley.toolbox.JsonObjectRequest
import com.android.volley.toolbox.Volley
import com.bumptech.glide.Glide

please assist me to resolve that...

  • That was kotlin synthetic which is deprecated now. Use View Binding or Data binding instead to access the views . – ADM Nov 07 '21 at 17:25

1 Answers1

0

Can do this using the traditional way, assuming you are not using Kotlin Synthetics or View Binding:

 val imageView = view.findViewById<ImageView>(R.id.abc)

Then do this at where you want to use the abc image view like this:

 Glide.with(this).load(url).into(imageView);

If you want to use the Kotlin Synthesis method, can follow this link here to add in the imports but it is not recommended anymore as it is deprecated to give way for View Binding.

Wilson Sim
  • 513
  • 1
  • 5
  • 15