This repository was archived by the owner on Jul 2, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +19
-6
lines changed
android/canonical/app/src/main/java/com/google/samples/quickstart/canonical Expand file tree Collapse file tree 1 file changed +19
-6
lines changed Original file line number Diff line number Diff line change @@ -29,15 +29,28 @@ class RunHistoryAdapter(
2929
3030 override fun getView (position : Int , convertView : View ? , parent : ViewGroup ): View {
3131 // Get view for row item
32- val rowView = convertView ? : inflater.inflate(R .layout.single_run_item, parent, false )
33- val timeTextView = rowView.findViewById<TextView >(R .id.single_run_time)
34- val datetimeTextView = rowView.findViewById<TextView >(R .id.single_run_datetime)
32+ val rowView : View
33+ val holder : ViewHolder
34+ if (convertView == null ) {
35+ rowView = inflater.inflate(R .layout.single_run_item, parent, false )
36+ holder = ViewHolder (rowView)
37+ rowView.tag = holder
38+ } else {
39+ rowView = convertView
40+ holder = rowView.tag as ViewHolder
41+ }
3542
3643 val singleRun = getItem(position) as ProfileViewModel .SingleRun
37- timeTextView.text = singleRun.time
38- datetimeTextView.text = singleRun.dateTime
44+ holder. timeTextView.text = singleRun.time
45+ holder. datetimeTextView.text = singleRun.dateTime
3946
4047 return rowView
4148 }
4249
43- }
50+ private class ViewHolder (row : View ) {
51+ val timeTextView: TextView = row.findViewById(R .id.single_run_time)
52+ val datetimeTextView: TextView = row.findViewById(R .id.single_run_datetime)
53+ }
54+
55+ }
56+
You can’t perform that action at this time.
0 commit comments