You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
getView( ) 오버라이드 부분을 뷰홀더 패턴 미적용 버전으로 한다면 다음과 같습니다.
코드는 더 짧은데 매번 레이아웃을 인플레이트하여 성능은 안 좋기 때문에 구글에서 뷰홀더 패턴 적용을 권장하고 있습니다.
그래서 ListView의 단점을 보완한 RecyclerView의 경우에는 뷰홀더 패턴이 강제되고 있습니다.
overridefungetView(position:Int, convertView:View?, parent:ViewGroup?): View? {
val view =LayoutInflater.from(parent?.context)
.inflate(R.layout.item_todo, parent, false)
val item = adapterData!![position]
val textView1:TextView= view.findViewById(R.id.text1)
val dateTextView:TextView= view.findViewById(R.id.text2)
textView1.text = item.title
dateTextView.text =DateFormat.format("YYYY/MM/dd", item.date)
return view
}
trxtView1이라는 변수를 만들어서 R,id,text1으로 직접 할당했습니다.
이렇게 바꾸니까 에러는 안나는데 텍스트 출력이 안되네요.ㅠㅠ
text1을 직접 지정해서 출력하는 방법은 없는지요.
조언 부탁합니다.
The text was updated successfully, but these errors were encountered: