Override the getCount function to return the number of steps
overridefungetCount(): Int {return route?.collapsedSteps?.size ?: 0}
Override the getView function to create your views that should be displayed in the list
overridefungetView(position: Int, convertView: View?, parent: ViewGroup?): View {//inflate you view, in this example we will just use a textViewval view =TextView(context) view.text = route?.let {"step #$position: ${route?.collapsedSteps?.get(position)?.htmlInstructions}" } ?: "No Route"return view}
Override getItem and getItemId to let click events work corretly
overridefungetItem(position: Int): MPRouteStep {return route?.collapsedSteps?.get(position) ?: throwIllegalStateException("Cannot select step that does not exist")}overridefungetItemId(position: Int): Long {return0L}
Now you can add the adapter to your ListView and show the route elements
val routeAdapter =RouteListAdapter()listview.adapter = routeAdapter