-
카테고리
-
세부 분야
모바일 앱 개발
-
해결 여부
미해결
recycleview강의에서 4분 12초에 .adapter부분이 빨간색이 떠요.
21.05.13 14:15 작성 조회수 254
0
7번째 recycleview강의라서 여기서 질문올렸어요.
ChatListActivity.kt
package com.example.chatting_video
import Model.UserItem
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.xwray.groupie.GroupAdapter
import com.xwray.groupie.GroupieViewHolder
import kotlinx.android.synthetic.main.activity_chat_list.*
class ChatListActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_chat_list)
val adapter = GroupAdapter<GroupieViewHolder>()
adapter.add(UserItem())
adapter.add(UserItem())
adapter.add(UserItem())
recyclerview_list.adapter = adapter
}
}
.adapter부분이 빨간색이 떠요. = adapter는 괜찮아요.
adapter부분에 뭐가 빠져서 빨간색이 뜨는것 같아요.
오류는 아래와 같아요
e: C:\Users\MS\AndroidStudioProjects\chatting_video\app\src\main\java\com\example\chatting_video\ChatListActivity.kt: (21, 27): Unresolved reference: adapter
UserItem.kt
package Model
import android.content.ClipData
import com.example.chatting_video.R
import com.xwray.groupie.GroupieViewHolder
import com.xwray.groupie.Item
class UserItem : Item<GroupieViewHolder>() {
override fun getLayout(): Int {
return R.layout.message_list_row
}
override fun bind(viewHolder: GroupieViewHolder, position: Int) {
}
}
activity_chat_list.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/recyclerview_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ChatListActivity">
<androidx.recyclerview.widget.RecyclerView
android:layout_width="344dp"
android:layout_height="572dp"
android:layout_marginStart="20dp"
android:layout_marginLeft="20dp"
android:layout_marginTop="40dp"
android:layout_marginEnd="20dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="40dp"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.761"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.632" />
</androidx.constraintlayout.widget.ConstraintLayout>
답변을 작성해보세요.
0
개복치개발자
지식공유자2021.05.15
recyclerview에 id를 달아주지 않았기 때문에 에러가 나는 겁니다.
recyclerview에 익숙하지 않다면 연습 후, 강의를 들으시면 어려움이 덜하실거에요!
https://www.youtube.com/watch?v=6Gm3eMG8KqI
0
개복치개발자
지식공유자2021.05.15
이 코드를
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/recyclerview_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ChatListActivity">
<androidx.recyclerview.widget.RecyclerView
android:layout_width="344dp"
android:layout_height="572dp"
android:layout_marginStart="20dp"
android:layout_marginLeft="20dp"
android:layout_marginTop="40dp"
android:layout_marginEnd="20dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="40dp"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.761"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.632" />
</androidx.constraintlayout.widget.ConstraintLayout>
아래와 같이 변경해주세요~
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ChatListActivity">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerview_list"
android:layout_width="344dp"
android:layout_height="572dp"
android:layout_marginStart="20dp"
android:layout_marginLeft="20dp"
android:layout_marginTop="40dp"
android:layout_marginEnd="20dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="40dp"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.761"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.632" />
</androidx.constraintlayout.widget.ConstraintLayout>
0
개복치개발자
지식공유자2021.05.15
xml 파일에 android:id="@+id/recyclerview_list"
이 부분이 constraintLayout아 아니라
recyclerView부분에 선언되어야 할 것 같습니다.
Tkhp Sch
질문자2021.05.15
무엇을 어떻게 하라는 말인가요? 구체적으로 적어주셔야 뭘해야하는지 알텐데 너무 생략하셔서 무엇을 어떻게 하는지 모르겠습니다.
recycleview부분에 잘라넣으란 말인가요?
답변 3