0

I'm just a beginner in Android application development. And I came to this creating ListView and manipulating content for the ListView. We all know we usually use Adapter as a data and View provider for the ListView. Have one doubt is this really falls under the normal Adapter Design Pattern. One more doubt I'm fetching the content for my list from a third party API. In this I'm using two types of Views one is to show the loading view while the content is getting loaded from the API and the other is the normal View(ListRow). Is it good way of doing it ? Any help or explanation would be largely appreciated.

Thank You

CodeDecode
  • 401
  • 2
  • 10
  • 19

2 Answers2

3

Android List Adapters follow creational object not structural pattern. I wonder why this name Adapters. They would have named it like some ItemListFactory.

CodeDecode
  • 401
  • 2
  • 10
  • 19
2

Android adapters are in fact the same Adapter design pattern as per the GoF. Adapters are used to give a known interface to unknown objects. eg: if we are using any 3rd party libraries, it is recommended to have adapters implemented so that the 3rd party interface is converted to a known interface. Then it becomes easy to replace the 3rp party libraries with just adding a new adapter.

Now, look at the ListView Adapter concept in Android as a whole. 3rd party developers are free to add any data backend and make the list view work if they implement the known interface which is the Android defined adapter kind. I hope that clarifies the design pattern.

Aun
  • 1,883
  • 1
  • 17
  • 26