> For the complete documentation index, see [llms.txt](https://docs.mapsindoors.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.mapsindoors.com/sdks-and-frameworks/android/directions/wayfinding-instructions/see-route-element-details.md).

# See Route Element Details

Android v4

In this tutorial we will request a route and list the route parts. A MapsIndoors route is made of one or more legs, each containing one or more steps.

Start by creating a `BaseAdapter` implementation with a `MPRoute` property, and include all the required functions.

```kotlin
class RouteListAdapter(private val context: Context) : BaseAdapter() {
    private var route: MPRoute? = null
 
    override fun getCount(): Int {
        TODO("Not yet implemented")
    }

    override fun getItem(position: Int): Any {
        TODO("Not yet implemented")
    }

    override fun getItemId(position: Int): Long {
        TODO("Not yet implemented")
    }

    override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View {
        TODO("Not yet implemented")
    }
}
```

Inside the `init` section, setup a directions service, call the directions service and save the route result to your `route` property

```kotlin
init {
    val origin = MPPoint(57.057917, 9.950361, 0.0)
    val destination = MPPoint(57.058038, 9.950509, 1.0)
    val service = MPDirectionsService()
    service.setRouteResultListener { route, error ->
        route?.let {
            this.route = it
            notifyDataSetChanged()
        }
        error?.let {
            Log.e("RouteListAdapter", it.toString())
        }
    }
    service.query(origin, destination)
}
```

Override the `getCount` function to return the number of steps

```kotlin
override fun getCount(): Int {
    return route?.collapsedSteps?.size ?: 0
}
```

Override the `getView` function to create your views that should be displayed in the list

```kotlin
override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View {

    //inflate you view, in this example we will just use a textView
    val 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

```kotlin
override fun getItem(position: Int): MPRouteStep {
    return route?.collapsedSteps?.get(position) ?: throw IllegalStateException("Cannot select step that does not exist")
}

override fun getItemId(position: Int): Long {
    return 0L
}
```

Now you can add the adapter to your `ListView` and show the route elements

```kotlin
val routeAdapter = RouteListAdapter()
listview.adapter = routeAdapter
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.mapsindoors.com/sdks-and-frameworks/android/directions/wayfinding-instructions/see-route-element-details.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
