-
Notifications
You must be signed in to change notification settings - Fork 1
[김예란_Android] 2주차 과제 제출 #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
kongwoojin
left a comment
There was a problem hiding this 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") | ||
| } |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
itemList.size와 itemList.lastIndex는 무슨 차이일까요?
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
몇가지 질문이 있습니다
- context란 무엇인가요
viewHolder.rootView.context는 어떤 context일까요- 다른 방법으로 context를 받을 수는 없을까요
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
불필요한 라이브러리 같은데, 추가하신 이유가 있을까요?
There was a problem hiding this comment.
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" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
여기도 불필요해보입니다
KYM-P
left a comment
There was a problem hiding this 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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
질문이 많으니 저도 질문
notifyItemRemoved(position) 을 호출하지 않으면 어떻게 될까요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
item,removeAt(position)으로 리스트에서 제거는 되지만 내용이 갱신되지 않아 오류가 발생합니다
No description provided.