Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Android Android Activity Lifecycle The Project Creating the Adapter

Alex Londono
Alex Londono
2,033 Points

How did you know you needed a list adapter and more importantly, that you needed to extend base adapter?

How did you know you needed a list adapter and more importantly, that you needed to extend base adapter?

1 Answer

Ben's solution to the problem was to use a ListView to display the list of rows with a hole number, stroke count, minus and plus button. Every list needs some kind of adapter because an adapter is a bridge between a list and a datasource. In other words, the adapter for this project is what helps the list know what should be displayed for each row. A Base Adapter is a superclass which is used for a number of Adapter types. In other words, it is what gives an adapter its ability to act as a bridge between the list and a datasource. It does so by doing some work for you in the background provided you implement its required methods. But using a Base Adapter was not the only way. It was also possible to use an Array Adapter. It you were to use a RecyclerView, it has its own Adapter pattern. This is the case where there is more than one way to solve the same problem but as Ben said you should not worry if your way of solving the problem is the same as his, just so long as yours works.