Skip to content

Conversation

@yeran27
Copy link

@yeran27 yeran27 commented Sep 30, 2025

No description provided.

Copy link

@kongwoojin kongwoojin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생하셨습니다!
몇가지 질문 사항을 남겨뒀으니, 답변 달아주시면 감사하겠습니다 :)

androidTestImplementation(libs.androidx.espresso.core)
val fragment_version = "1.8.9"
implementation("androidx.fragment:fragment-ktx:$fragment_version")
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

newline에 대해 알아보시면 좋을 것 같습니다

import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView

data class ListItem(val name: String)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

별도의 class이니 별도의 파일로 분리하는게 좋아보이네요

val name = editText.text.toString()
if (name.isNotEmpty()){
itemList.add(ListItem(name))
adapter.notifyItemInserted(itemList.size -1)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

itemList.sizeitemList.lastIndex는 무슨 차이일까요?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

itemList.size는 리스트의 전체 요소 개수이며, itemList.lastIndex는 리스트의 마지막 요소의 인덱스입니다

override fun onBindViewHolder(viewHolder: ViewHolder, position: Int){
viewHolder.nameText.text = items[position].name
viewHolder.rootView.setOnClickListener {
AlertDialog.Builder(viewHolder.rootView.context)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

몇가지 질문이 있습니다

  1. context란 무엇인가요
  2. viewHolder.rootView.context는 어떤 context일까요
  3. 다른 방법으로 context를 받을 수는 없을까요

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

그 작업을 어느 activity에서 할건지 알려주는 것이라고 생각합니다
viewHolder.rootView.context는 RecyclerView가 속한 Activity의 Context입니다
현재는 view에서 가져오고 있지만 생성자로 받을 수 있으며 this로 지명할 수 있습니다

app:layout_constraintTop_toTopOf="parent" />

<Button
android:id="@+id/button_add"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

naming convention 잘 지키셨네요!
다만 조금 더 명확하게 이름을 짓는다면, button_add_item은 어떨까 싶네요

androidTestImplementation(libs.androidx.junit)
androidTestImplementation(libs.androidx.espresso.core)
val fragment_version = "1.8.9"
implementation("androidx.fragment:fragment-ktx:$fragment_version")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

불필요한 라이브러리 같은데, 추가하신 이유가 있을까요?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

처음에 fragment를 이용하여 풀어보려 했는데 결국엔 사용하지 않았습니다. 그 과정에서 미처 지우지 못했습니다

material = "1.12.0"
activity = "1.11.0"
constraintlayout = "2.2.1"
fragment_version = "1.8.9"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여기도 불필요해보입니다

Copy link
Collaborator

@KYM-P KYM-P left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

트랙장님의 고난도 질문이 많아서 제가 할게 없네요.
다른건
`6.아이템을 길게 누르면 수정 여부를 묻는 AlertDialog가 표시됩니다.

  • EditText를 포함해야 합니다.`
    의 구현 요소를 빼먹으셨습니다.

.setMessage(R.string.dialog_message)
.setPositiveButton(R.string.dialog_positive_message) { dialog, _ ->
items.removeAt(position)
notifyItemRemoved(position)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

질문이 많으니 저도 질문
notifyItemRemoved(position) 을 호출하지 않으면 어떻게 될까요?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

item,removeAt(position)으로 리스트에서 제거는 되지만 내용이 갱신되지 않아 오류가 발생합니다

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants