강의

멘토링

커뮤니티

Inflearn Community Q&A

lee10665152196's profile image
lee10665152196

asked

[Absolute Beginner] Learn Android Kotlin by building 8 apps

MangoPlate App Introduction and Layout - RecyclerView, Glide

코드에서 text부분에 오류가 발생했습니다.

Written on

·

296

0

package com.example.mangoplate

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import androidx.recyclerview.widget.RecyclerView
import com.bumptech.glide.Glide
import kotlinx.android.synthetic.main.activity_main.*
class rvadapter(val context : Context, val List : MutableList<contentsmodel>):RecyclerView.Adapter<rvadapter.ViewHolder>(){
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): rvadapter.ViewHolder {
val v = LayoutInflater.from(parent.context).inflate(R.layout.rv_item,parent,false)
return ViewHolder(v)
}

override fun onBindViewHolder(holder: rvadapter.ViewHolder, position: Int) {
holder.bindItems(List[position])
}

override fun getItemCount(): Int {
return List.size
}

inner class ViewHolder(itemView : View) : RecyclerView.ViewHolder(itemView){
fun bindItems(item : contentsmodel){

//바인딩을 하는 곳이다.
val rv_img = itemView.findViewById<ImageView>(R.id.rvimagearea)
val rv_text = itemView.findViewById<ImageView>(R.id.rvtextarea)

rv_text.text = item.titleText
Glide.with(context)
.load(item.ImageURL)
.into(rv_img)
}
}

//다른 것은 다 잘 되었는데, text만 오류가 발생했습니다.
//오류 해결 방법을 여쭙고 싶습니다.
//항상 수업 잘 듣고 있습니다!!
}
firebasekotlinandroid

Answer 1

0

bokchi님의 프로필 이미지
bokchi
Instructor

어떤 오류인지와 함께 오류메세지를 알려주세요~

lee10665152196님의 프로필 이미지
lee10665152196
Questioner

네!! unresloved reference : text 라는 오류가 발생합니다!

bokchi님의 프로필 이미지
bokchi
Instructor

val rv_text = itemView.findViewById<ImageView>(R.id.rvtextarea)

이 곳에 ImageView가 아닌 TextView가 아닐까 생각듭니다.

lee10665152196님의 프로필 이미지
lee10665152196
Questioner

앗! 감사합니다!!

lee10665152196's profile image
lee10665152196

asked

Ask a question