API Reference / Android Widgets / stats
Apr. 24, 2019
Widget signature
<com.algolia.instantsearch.ui.views.Stats
  android:id="@+id/stats"

  <!-- Optional parameters -->
  algolia:errorTemplate="string"
  algolia:resultTemplate="string"
  algolia:autoHide="boolean"
  algolia:variant="string"
/>

About this widget

Stats is a widget for displaying statistics about the current search result.

Examples

1
2
3
4
5
6
7
<com.algolia.instantsearch.ui.views.Stats
    android:id="@+id/hitCount"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    algolia:errorTemplate="@string/error_template"
    algolia:resultTemplate="@string/result_template" />

Parameters

resultTemplate
type: string

What the widget displays when a search request returns successfully. It takes the form of a templated string with the following templates to replace:

  • {nbHits}: the hit count for the current query.
  • {processingTimeMS}: the time the server took to process the request, in milliseconds.
  • {hitsPerPage}: the maximum number of hits returned per page.
  • {nbPages}: the number of pages corresponding to the number of hits.
  • {page}: the index of the current page (zero-based).
  • {query}: the query text.

The default resultTemplate is “{nbHits} results found in {processingTimeMS} ms”.

1
algolia:resultTemplate="{nbHits} results found in {processingTimeMS} ms"
errorTemplate
type: string

What the widget displays when a search query returns with an error. It takes the form of a templated string with the following templates to replace:

  • {error}: the error message
  • {query}: the query text
1
algolia:errorTemplate="There was an error ({error}), please try again"
autoHide
type: boolean
default: false

Whether the widget should be hidden when there are no results.

1
algolia:autoHide="true"
variant
type: string

An identifier for the widget group this widget is part of. If specified, this widget is only linked to other widgets that have the same variant. See Multi-Index Searches.

1
algolia:variant="actors"

Did you find this page helpful?