kotlin 来自Glide.,显示ImageView Android Studio

gojuced7  于 2023-01-26  发布在  Kotlin
关注(0)|答案(1)|浏览(135)

我试图解决这个问题,但我没有找到任何东西,直到现在。所以我的图像视图是一个字符串,我试图调用它与滑翔。与和许多更多,但不幸的是没有成功,直到现在。它应该是一个简单的代码行,但我没有找到它。

class ImageInformation : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_image_information)


            val image = intent.getParcelableExtra<ImageModel>("image")
            if (image != null){
                val downloadUrl: TextView = findViewById(R.id.downloadUrla)
                val previewUrl : ImageView = findViewById(R.id.previewUrls)
                val id: TextView = findViewById(R.id.idsa)
                val filename: TextView = findViewById(R.id.fileNamea)
                val filesize: TextView = findViewById(R.id.filesizea)
                val contentType: TextView = findViewById(R.id.contentTypea)
                val createdBy: TextView = findViewById(R.id.createdBya)
                val createdTimestamp: TextView = findViewById(R.id.createdTimestampa)
                val creationSource: TextView = findViewById(R.id.creationSourcea)
                val domainIdentityType: TextView = findViewById(R.id.domainIdentityTypea)
                val domainIdentityValue: TextView = findViewById(R.id.domainIdentityValuea)
                val tags: TextView = findViewById(R.id.tagsa)
                val description: TextView = findViewById(R.id.descriptiona)


                    downloadUrl.text = image.downloadUrl

                     

TO DO, Preview URL
                    //previewUrl.setImageResource(image.previewUrl)//Required Int not a String.
                    //Glide.with(this).load( previewUrl).into(previewUrl)
                    //Glide.with(Activity()).load(previewUrl).centerInside().into(previewUrl)
                    //previewUrl.setImageResource(image.previewUrl)
                    //Glide.with(Activity()).load(previewUrl).into(image.previewUrl)          
                    //Glide.with(this).load(previewUrl).centerInside().into(image.previewUrl)
                    //previewUrl.setImageResource(image.previewUrl)

                    //Nothing from the above lines doesn#t work. 

                    id.text = image.id
                    filename.text = image.fileName
                    filesize.text = image.filesize.toString()
                    contentType.text = image.contentType
                    createdBy.text = image.createdBy
                    createdTimestamp.text = image.createdTimestamp
                    creationSource.text = image.creationSource
                    domainIdentityType.text = image.domainIdentityType
                    domainIdentityValue.text = image.domainIdentityValue
                    tags.text = image.tags.toString()
                    description.text = image.description


            }
}
}
5m1hhzi4

5m1hhzi41#

试试这个:

Glide.with(context)
    .load(image.downloadUrl) // here we are telling Glide what it needs to load
    .into(previewUrl) // here we are telling Glide where to load it into (your imageView)

我必须说,您对ImageView(previewUrl)的命名确实使它很难阅读,将其重命名为previewImageView之类的名称可能会更好。

相关问题