Android教程網
  1. 首頁
  2. Android 技術
  3. Android 手機
  4. Android 系統教程
  5. Android 游戲
 Android教程網 >> Android技術 >> Android開發 >> 高級開發 >> Android 3.0 SDK中新增API詳解

Android 3.0 SDK中新增API詳解

編輯:高級開發

 android 3.0 SDK中新增了哪些API呢? 我們總結下平板系統honeycomb中的新特性, 首先需要澄清的是經過android123發現設置模擬器的分辨率到普通WVGA這樣的解析度時平板的特性自動消失和Android 2.3沒有什麼太大區別,按照這樣來看未來android 3.0除了兼容平板外還繼續可以被手機所支持,據稱3.0的代碼針對A9雙核CPU進行了進一步的改進。

  一、Fragments 碎片容器

  有關Android Fragments的內容,android開發網在前幾天已經用幾篇文章詳細講解了下,大家可以從Fragment對比Activity - android碎片介紹 一文開始了解。

  二、Action Bar 活動欄

  活動欄Action Bar可以替換傳統的標題欄在Activity窗口中,包括程序圖標和一些新接口在activity的選項菜單中,另外Action Bar允許你

  Include select menu items directly in the Action Bar—as "action items"—for quick Access to global user actions.

  In your XML declaration for the menu item, include the attribute, android:showAsAction with a value of "ifRoom". When there's enough room in the Action Bar, the menu item appears directly in the bar. Otherwise, the item is placed in the overflow menu, revealed by the icon on the right side of the Action Bar.

  Add interactive widgets to the Action Bar—as "action vIEws"—such as a search box.

  In the XML for the menu item that should behave as an action view, include the android:actionViewLayout attribute with a layout resource for the action vIEw or android:actionViewClass with the class name of the widget. Like action items, an action view appears only when there's room for it in the Action Bar. If there's not enough room, it is placed in the overflow menu and behaves like a regular menu item (for example, an item can provide a SearchView as an action vIEw, but when in the overflow menu, selecting the item activates the search dialog).

  Add an action to the application logo when tapped and replace it with a custom logo

  The application logo is automatically assigned the android.R.id.home ID,

  接上頁

which the system deliveres to your activity's onOptionsItemSelected() callback when tapped. Simply respond to this ID in your callback method to perform an action such as go to your application's "home" activity.

  To replace the icon with a logo,

  Add breadcrumbs for navigating backward through fragments

  Add built in tabs and a drop-down list for navigation

  Customize the Action Bar themes and custom backgrounds

  有關ActionBar的文章,可以參考 Action Bar使用方法 - android活動欄 系列文章

  三、System clipboard系統剪切板

  Android 3.0中的剪切板進行了增強,本次可以支持除了純文本外更多的內容,如,URL和Intent,對於剪切板類ClipboardManager仍然通過 getSystemService(CLIPBOARD_SERVICE)來實例化,新增的ClipData類用於管理具體的復制對象,可以在SDK的 android.content.ClipData.Item中找到。 具體的使用android123將在今後的文章中寫道。

  四、拖拽

  開始拖拽內容在你的Activity中可以使用startDrag()方法在一個View中,這裡View.DragShadowBuilder提供了拖拽時的陰影,對於拖拽的過程處理可以通過OnDragListener通過VIEw的setOnDragListener()來設置,在拖拽的時候系統會自動調用onDrag()方法。

  五、增強的appWidgets

  android 3.0的appWidget開始支持更豐富的控件,比如GridView, ListView, StackView, ViewFlipper和AdapterViewFlipper.而以前必須通過RemoteView顯示一個文本或圖片,本次全新的 RemoteVIEwsService增強了桌面小插件的功能

  六、增強的狀態提示欄

  新增的Notification API可以豐富你的狀態欄,新的Notification.Builder類可以幫助你輕松實現,支持大圖標提示信息通過setLargeIcon方法, 通常顯示一些社交類的軟件,比如聯系人照片,或相冊縮略圖,設置自定義狀態欄,可以使用setTicker()方法。

  七、內容加載器

  新框架API提供了一個異步加載內容的淚,合並和UI組件和fragment來動態加載數據從工作者現成,使用CursorLoader子類來獲取ContentResolver中的數據.

  八、A2DP藍牙和耳機控制API

  android honeycomb中沒有忘記再次增強藍牙,你可以通過初始化BluetoothProfile通過調用getProfileProxy()在處理 A2DP或耳機

  接上頁

HEADSET設置,BluetoothProfile.ServiceListener可以獲取客戶端連接或斷開的回調。

  九、動畫框架

  3.0中android再次增強動畫播放類,ObjectAnimator和LayoutTransition需要大家了解一些。

  十、擴展UI框架

  新增以下UI控件

  AdapterVIEwAnimator

  AdapterVIEwFlipper

  CalendarVIEw

  ListPopupWindow

  NumberPicker

  PopupMenu

  SearchVIEw

  StackVIEw

  十一、圖形相關

  1. 2D圖形硬件加速Hardware accelerated 2D graphics , 在androidmanifest.XML的 元素中添加android:hardwareAccelerated="true" 即可。他可以優化程序運行更平滑高效,在滾動和動畫方面。

  2.設置渲染模式,比如 LAYER_TYPE_HARDWARE 硬件加速和 LAYER_TYPE_SOFTWARE 使用 setLayerType() 方法.

  3.渲染腳本對於3D圖形方面大家可以看看Renderscript類。

  上面是Android 3.0的主要改進,明天android開發網將和大家一起說下強大的對於平板電腦比較重要的Action Bar活動欄。

  1. 上一頁:
  2. 下一頁:
熱門文章
閱讀排行版
Copyright © Android教程網 All Rights Reserved