Не могу изменить текст в TextView Kotlin

Рейтинг: 0Ответов: 1Опубликовано: 31.01.2023

Страница:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    xmlns:tools="http://schemas.android.com/tools"
    android:orientation="vertical">

    <TextView
        android:id="@+id/tvTitle"
        android:layout_width="match_parent"
        tools:text="Hello World"
        android:textColor="@color/black"
        android:textSize="20sp"
        android:layout_height="wrap_content"/>
    <TextView
        android:id="@+id/tvBody"
        android:layout_width="match_parent"
        tools:text="Hello World"
        android:textSize="14sp"
        android:layout_height="wrap_content"/>

</LinearLayout>

Класс:

import android.view.TextureView
import android.view.View
import androidx.recyclerview.widget.RecyclerView

class PostAdapter {
}

class PostViewAdapter(itemView: View) : RecyclerView.ViewHolder(itemView) {
    private val tvTitle : TextureView = itemView.findViewById(R.id.tvTitle)
    private val tvBody : TextureView = itemView.findViewById(R.id.tvBody)

    fun bindView(postModel: PostModel) {
        tvTitle.text
    }
}

Не могу обратиться к полю "text" Unresolved reference. В чем проблема может быть?

Ответы

▲ 2

Unresolved reference "text" возникает, потому что "TextureView" не имеет свойства "text". Вам нужно использовать "TextView" вместо "TextureView".