Widget简介及基本开发方法.ppt

上传人:牧羊曲112 文档编号:6523452 上传时间:2023-11-08 格式:PPT 页数:28 大小:326.50KB
返回 下载 相关 举报
Widget简介及基本开发方法.ppt_第1页
第1页 / 共28页
Widget简介及基本开发方法.ppt_第2页
第2页 / 共28页
Widget简介及基本开发方法.ppt_第3页
第3页 / 共28页
Widget简介及基本开发方法.ppt_第4页
第4页 / 共28页
Widget简介及基本开发方法.ppt_第5页
第5页 / 共28页
点击查看更多>>
资源描述

《Widget简介及基本开发方法.ppt》由会员分享,可在线阅读,更多相关《Widget简介及基本开发方法.ppt(28页珍藏版)》请在三一办公上搜索。

1、Widget简介及基本开发方法,Widget(微件)是一块可以在任何基于HTML的Web页面上执行的代码,表现形式可能是视频,地图,新闻,小游戏等。,Widget起源,Widget的创想来苹果公司电脑工程师Rose1998年,Rose在Mac操作系统使用一个可以更换皮肤的MP3播放器时突发奇想:如果桌面上运行的所有工具都能够更换皮肤或外观,将是很酷的事情,他称之为“Konfabulator”,2003年2月Konfabulator1.0正式发布运行在苹果操作系统上的小工具其中的主执行文件叫Widget2003年7月Konfabulator1.5发布主执行文件Widget的开发开始流行,Konf

2、abulator更名为Widget2004年11月Widget1.8发布Widget支持Windows和Mac操作系统,Widget的主要特征,身材微:一般尺寸很小,方便嵌入终端快速运行功能巨:Widget能够主动从互联网获取信息形式多:Widget有多种呈现形式,如幻灯秀、视频、地图、新闻、小游戏姿容丽:Widget将狭窄单调的浏览器窗口变为广阔绚丽的桌面空间个性化:用户可以根据自己的喜好,将多个Widget重新排列组合成自己的互联网桌面易制作:Widget制作简单,需要使用图像处理工具,具备HTML/XML和Java知识,-网络整合营销兵器谱,Widget vs.普通网页,Widget 无

3、需浏览器可以直接显示在桌面Widget可以同时与多个Web服务器上的不同Web服务交互Widget 有一个 widget 对象通过 JavaScript 调用该对象的函数Widget 在本地有一个永久的存储空间类似于Cookies机制的保存设置和下载信息Widget 通常有多个视图通过JavaScript/CSS 技术实现视图间的切换Widget默认可以拖动可以指出不响应拖动的控制域Widget默认背景是透明的Widget的透明部分不响应任何鼠标事件,典型Widget包含的文件,Widget 配置文件Widget 配置文件根目录,包含Widget的基本信息,如名称、尺寸、作者和安全信息。首页文

4、件类似于网页中的 index文件,给出Widget 的基本结构和内容。图像所有图像文件都在名为 images 的文件夹中。JavaScript 脚本文件所有脚本文件都在名为 script 的文件夹中。Stylesheet 样式表文件所有样式表单都在名为 style 的文件夹中。,Widget开发的技术要求,Web相关技术的基础知识Web 设计 IDE 软件或创建 JavaScript,HTML 和 CSS 文件的文本编辑器创建.zip 文件的工具发布Widget的网站,常见Widget,桌面WidgetYahoo!WidgetGoogle WidgetOpera Widgethttp:/Wid

5、get Samsung Widget JIL Widget Android Widget,社交网站WidgetFacebook Widget人人网/开心网 Widget盛大 Widget,Android发展历史,2003年Android成立2005年Google并购Android 2007年11月发布Android2008年9月发布Android 1.02009年2月发布Android 1.12009年4月发布Android 1.5(Cupcake)2009年9月发布Android 1.6(Donut)2009年10月发布Android 2.0(Eclair)2010年1月发布Android

6、2.12010年5月发布Android 2.2(Froyo)2010年10月发布Android 3.0(Gingerbread)?年?月发布Android 3.5(Honeycomb),Android开发环境,开发环境Java运行时库(JRE)Android SDK 2.2Eclispe3.*ADT Plugin for Eclipse Android API Reference链接 http:/androidappdocs-,Android Widgets,Widgets are a feature introduced in Android 1.5.A widget displays an

7、 applications most important or timely information at a glance,on a users Home screen.Android widgets have three main components:a bounding boxa framethe widgets graphical controls and other elements,Android App Widgets,App Widgets are miniature application views that can be embedded in other applic

8、ations and receive periodic updates.These views are referred to as Widgets in the user interfaceUsers can publish Widgets with an App Widget provider.An application component that is able to hold other App Widgets is called an App Widget host.,Basics of Android App Widgets,AppWidgetProviderInfo obje

9、ct Describes the metadata for an App Widget in XML,such as the App Widgets layout,update frequency,and the AppWidgetProvider class.AppWidgetProvider class implementation Defines the basic methods that allow you to programmatically interface with the App Widget,based on broadcast events.Through it,yo

10、u will receive broadcasts when the App Widget is updated,enabled,disabled and deleted.View layout Defines the initial layout for the App Widget in XML.App Widget configuration Activity implement.This is an optional Activity that launches when the user adds an App Widget and allows user to modify App

11、 Widget settings at create-time.,Declaring an App Widget in Manifest,Declare the AppWidgetProvider class in your applications AndroidManifest.xml file.,Adding the AppWidgetProviderInfo Metadata,The AppWidgetProviderInfo defines the essential qualities of an App Widgetsuch as its minimum layout dimen

12、sions,its initial layout resource,how often to update the App Widget,and(optionally)a configuration Activity to launch at create-time.Define the AppWidgetProviderInfo object in an XML resource using a single element and save it in the projects res/xml/folder.,Creating the App Widget Layout,Define an

13、 initial layout for your App Widget in XML and save it in the projects res/layout/directory.Be familiar with Declaring Layout in XMLBe aware of RemoteViews,Using the AppWidgetProvider Class,The AppWidgetProvider class extends BroadcastReceiver to handle the App Widget broadcasts.The AppWidgetProvide

14、r receives only the event broadcasts that are relevant to the App Widgetsuch as when the App Widget is updated,deleted,enabled,and disabled.,When these broadcast events occur,the AppWidgetProvider receives the following method calls:onUpdate(Context,AppWidgetManager,int)onDeleted(Context,int)onEnabl

15、ed(Context)onDisabled(Context)onReceive(Context,Intent),AppWidgetProvider is a convenience class.If you would like to receive the App Widget broadcasts directly,you can implement your own BroadcastReceiver or override the onReceive(Context,Intent)callback.The four Intents:ACTION_APPWIDGET_UPDATE ACT

16、ION_APPWIDGET_DELETED ACTION_APPWIDGET_ENABLED ACTION_APPWIDGET_DISABLED,Creating an App Widget Configuration Activity,An App Widget configuration Activity is needed if users want to configure settings when he or she adds a new App Widget.Activity will be automatically launched by the App Widget hos

17、t and allows the user to configure available settings for the App Widget at create-time,such as the App Widget color,size,update period or other functionality settings.,The configuration Activity should be declared as a normal Activity in the Android manifest file.It will be launched by the App Widg

18、et host with the ACTION_APPWIDGET_CONFIGURE action.,The configuration Activity must be declared in the AppWidgetProviderInfo XML file,with the android:configure attribute.,Implement the actual Activity The App Widget host calls the configuration Activity and the configuration Activity should always

19、return a result.The result should include the App Widget ID passed by the Intent that launched the Activity(saved in the Intent extras as EXTRA_APPWIDGET_ID).The onUpdate()method will not be called when the App Widget is created(the system will not send the ACTION_APPWIDGET_UPDATE broadcast when a c

20、onfiguration Activity is launched).It is the responsibility of the configuration Activity to request an update from the AppWidgetManager when the App Widget is first created.However,onUpdate()will be called for subsequent updatesit is only skipped the first time.,Android网络资源,Android官方网站 http:/Android开发网http:/http:/http:/,

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 生活休闲 > 在线阅读


备案号:宁ICP备20000045号-2

经营许可证:宁B2-20210002

宁公网安备 64010402000987号