Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 4c21681

Browse files
author
deeper
committed
init adapter pattern
1 parent 680273e commit 4c21681

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

‎src/com/ruoxu/pattern/adapter/Demo.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package com.ruoxu.pattern.adapter;
2+
3+
/**
4+
* 适配器模式
5+
* 适配器模式分为两种:
6+
* 1.类适配器模式。
7+
* 2.对象适配器模式,
8+
* 其中类适配器模式虽然可以使用Java接口实现,但是却暴露了被适配器类的method(用户可能因为这样而困惑),故这里只实现对象适配器模式。
9+
*
10+
* 扩展:
11+
* Adapter的应用场景
12+
* 1.应用于->进行不兼容的类型转换
13+
* 2.应用于->输入时有无数种情况,但是输出时是统一的,可以利用Adapter返回一个统一的输出,而具体的输入留给用户处理,
14+
* 内部只需知道输出的是符合要求的类型即可。
15+
*
16+
* 最典型的的案例就是Android随处可见的Adapter,如ListView中的Adapter,用户的输入的ItemView各式各样,
17+
* 但最终都是属于View类型,ListView只需知道getView返回的是一个View即可。
18+
*
19+
* 此处只实现 场景1
20+
*
21+
* @author Limitless
22+
*
23+
*/
24+
public class Demo {
25+
public static void main(String[] args) {
26+
27+
}
28+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /