O'Reilly logo

Reactive Android Programming by Tadas Subonis

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding RecyclerView

Since the application will be displaying changes of financial stocks over time, it means that we will be working with data that's represented best as a list. For this, we will use RecyclerView

First of all, add it to your activity_main.xml file:

<android.support.v7.widget.RecyclerView    android:id="@+id/stock_updates_recycler_view"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:layout_below="@id/hello_world_salute" />

Then, inject it into your code with the following:

@BindView(R.id.stock_updates_recycler_view)RecyclerView recyclerView;

The next step is to initialize it in your activity:

private LinearLayoutManager layoutManager;private StockDataAdapter stockDataAdapter;...recyclerView ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required