Proxying to the New APIs 代理新的API
来源:互联网 发布:cisco查看mac地址表 编辑:程序博客网 时间:2024/05/27 01:23
Implement Tabs Using New APIs
The concrete classes for CompatTab
and TabHelper
that use newer APIs are aproxy implementation.
You can directly use newer APIs in these concrete classes—and not crash on earlier devices—because of lazy class loading. Classes are loaded and initialized on first access—instantiating the class or accessing one of its static fields or methods for the first time. Thus, as long as you don't instantiate the Honeycomb-specific implementations on pre-Honeycomb devices, the Dalvik VM won't throw anyVerifyError
exceptions. http://blog.csdn.net/sergeycao
A good naming convention for this implementation is to append the API level or platform version code name corresponding to the APIs required by the concrete classes. For example, the native tab implementation can be provided byCompatTabHoneycomb
and TabHelperHoneycomb
classes, since they rely on APIs available in Android 3.0 (API level 11) or later.
Implement CompatTabHoneycomb
CompatTabHoneycomb
is the implementation of the CompatTab
abstract class thatTabHelperHoneycomb
uses to reference individual tabs.CompatTabHoneycomb
simply proxies all method calls to its containedActionBar.Tab
object.
Begin implementing CompatTabHoneycomb
using the new ActionBar.Tab
APIs:
public class CompatTabHoneycomb extends CompatTab { // The native tab object that this CompatTab acts as a proxy for. ActionBar.Tab mTab; ... protected CompatTabHoneycomb(FragmentActivity activity, String tag) { ... // Proxy to new ActionBar.newTab API mTab = activity.getActionBar().newTab(); } public CompatTab setText(int resId) { // Proxy to new ActionBar.Tab.setText API mTab.setText(resId); return this; } ... // Do the same for other properties (icon, callback, etc.)}
Implement TabHelperHoneycomb
TabHelperHoneycomb
is the implementation of the TabHelper
abstract class that proxies method calls to an actualActionBar
, obtained from its containedActivity
.
Implement TabHelperHoneycomb
, proxying method calls to the ActionBar
API:
public class TabHelperHoneycomb extends TabHelper { ActionBar mActionBar; ... protected void setUp() { if (mActionBar == null) { mActionBar = mActivity.getActionBar(); mActionBar.setNavigationMode( ActionBar.NAVIGATION_MODE_TABS); } } public void addTab(CompatTab tab) { ... // Tab is a CompatTabHoneycomb instance, so its // native tab object is an ActionBar.Tab. mActionBar.addTab((ActionBar.Tab) tab.getTab()); } // The other important method, newTab() is part of // the base implementation.}
- Proxying to the New APIs 代理新的API
- Abstracting the New APIs 抽象出新的API
- Intro to the three Android Audio APIs 介绍 Android的三种音频API。
- Dynamics CRM 2015 Update 1 系列(3): API的那些事 - Old APIs VS New APIs
- Update the SAFCode project to the new LLVM API
- the SDK platform-tools version(xxx) is too old to check APIs cimpiled with API xxx.
- The SDK platform-tools version(24) is too old to check APIs compiled with API 25
- The SDK platform-tools version 23 is too old to check APIs compiled with API 24... ...
- 新的倒数之日 All New Dreamdays - Countdown to the Days that Matter
- Odoo ORM API(七)- Porting from the old API to the new API
- 新的开端(The New Beginning)
- Intro to the three Android Audio APIs
- Intro to the three Android Audio APIs
- 解决The SDK platform-tools version ((23)) is too old to check APIs compiled with API 23
- The SDK platform-tools version (20) is too old to check APIs compiled with API(x)
- Error: The SDK platform-tools version ((23)) is too old to check APIs compiled with API 23
- The SDK platform-tools version (24.0.4) is too old to check APIs compiled with API 25
- Android Studio运行问题:the SDK platform-tools version(24) is too old to check APIs cimpiled with API 25
- Android开发之Services详解
- BitBlaze(五) - 应用及相关工作
- Abstracting the New APIs 抽象出新的API
- 《北极熊为什么是白色的——人人都需要知道的进化论》读书笔记
- file外部表--有更新版本!
- Proxying to the New APIs 代理新的API
- 设置C#编译环境
- 书后思考:输出三个数中的中间数。从小到大输出三个数
- java实现zip压缩文件/文件夹
- Creating an Implementation with Older APIs 用较早版本的APIs实现抽象类
- 不能为虚拟电脑 xxx 打开一个新任务. Failed to load VMMR0.r0 (VERR_SUPLIB_OWNER_NOT_ROOT). 返回 代码:NS_ERROR_FAIL
- iOS 6.x 旋转问题
- Using the Version-Aware Component 使用版本识别组件
- 源程序丢失了一部分,可通过 ILSpy 对 EXE 项目文件反编译