Share via


GridViewPager

This guide demonstrates how to implement the 2D picker navigation pattern for Android Wear.

Example screenshot of GridViewPager on a square display

First add the Xamarin Android Wear Support NuGet package to your project.

The layout XML looks like this:

<android.support.wearable.view.GridViewPager xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/pager"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:keepScreenOn="true" />

Create a GridPagerAdapter (or subclass such as FragmentGridPagerAdapter to supply views to display as the user navigates.

The sample adapter shows how to implement the required methods, including overrides for RowCount, GetColumnCount, GetBackground, and GetFragment

Wire up the adapter as shown:

pager.Adapter = new SimpleGridPagerAdapter (this, FragmentManager);