Android的BaseAdapter是适配器模式的示例吗? [英] Is Android's BaseAdapter an example of Adapter pattern?

查看:270
本文介绍了Android的BaseAdapter是适配器模式的示例吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Android的类BaseAdapter在其名称中具有适配器,因为它遵循适配器模式,还是巧合?

解决方案

从维基百科


在计算机编程中,适配器模式(通常称为
包装器模式或简单地包装器)是一种设计模式,
将类的一个界面转换为兼容界面。 1
一个适配器允许类工作在一起,因为不兼容的接口通常不能
,通过在使用原始接口时向
客户端提供接口。


所以,让我们来解释一下。 BaseAdapters指定要用于需要适配器的程序的接口。其实这个界面叫做Adapter。此接口指定采取任意列表所需的信息,并将其转换为任意长的视图集。 BaseAdapter因此适应您的自定义输入格式(特别是如果您扩展它)到适配器接口。因此,它是适配器设计模式。


Does Android's class BaseAdapter have "Adapter" in its name because it follows the Adapter pattern or is it just a coincidence?

解决方案

From Wikipedia

In computer programming, the adapter pattern (often referred to as the wrapper pattern or simply a wrapper) is a design pattern that translates one interface for a class into a compatible interface.1 An adapter allows classes to work together that normally could not because of incompatible interfaces, by providing its interface to clients while using the original interface.

So, let's discect that. BaseAdapters specify an interface to use for programs that need adapters. In fact, this interface is called Adapter. This interface specifies the information needed to take an arbitrary list, and convert it to an arbitrarily long set of Views. BaseAdapter thus adapts your custom input format (In particularly, if you extend it), to the Adapter interface. Thus, it is an Adapter design pattern.

这篇关于Android的BaseAdapter是适配器模式的示例吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆