The adapter pattern

In the example we have been studying here, we used an adapter pattern to connect our data with our layout in the form of our DataAdapter. This is a ready-made adapter and although it is clear how it works, it teaches us nothing about the structure of the adapter or how to construct one ourselves.

There are many cases where Android provides built in patterns, which is very useful, but there will often be times when we need an adapter for classes we have created ourselves, and we will now see how this is done and also how to create the associated design pattern, the bridge. It is best to begin by looking at these patterns conceptually.

The purpose of the adapter is perhaps the easiest to understand. A good analogy would be the ...

Get Android Design Patterns and Best Practice now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.