Widget Example‎ > ‎

Slideshow


这里我们将Google Playground的Slideshow例子嵌入到Droidget中。

用Google Playground生成代码

从Google Playground的[Feed]-[Slideshow of Photo Feed]里,复制Slideshowの源代码。




<!--
  copyright (c) 2009 Google inc.

  You are free to copy and use this sample.
  License can be found here: http://code.google.com/apis/ajaxsearch/faq/#license
-->

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <title>Slideshow</title>
    <!-- Scripts for the slideshow -->
    <script src="http://www.google.com/jsapi" type="text/javascript"></script>
    <script src="http://www.google.com/uds/solutions/slideshow/gfslideshow.js"
            type="text/javascript"></script>
    <style type="text/css">
      #picasaSlideshow {
        width:  250px;
        height200px;
        margin-bottom40px;
        padding5px;
      }
    </style>
    <script type="text/javascript">
    /*
    *  How to make a slideshow with a photo feed using our custom control.
    *  To see the options, go here or click the docs link in the titlebar:
    *  http://www.google.com/uds/solutions/slideshow/index.html
    */
    
    google.load("feeds""1");
    
    function OnLoad({
      var feed  "http://dlc0421.googlepages.com/gfss.rss";
      var options {
        displayTime:2000,
        transistionTime:600,
        scaleImages:true,
        fullControlPanel true
      };
      var ss new GFslideShow(feed"picasaSlideshow"options);
    }
    
    google.setOnLoadCallback(OnLoad);
    </script>
  </head>
  <body style="font-family: Arial, sans-serif;border: 0 none;">
  <div id="picasaSlideshow" class="gslideshow"><div class="feed-loading">Loading...</div></div>
  </body>
</html>

新建项目

从Eclipse的菜单里选择[New]-[Project],当[New Project]对话框弹出后,选择"Droidget Wizard"-"project"
由于Slideshow需要从网上得到图片,因此需要指定网上图片的URL网址。

要想完成本例,必须得到访问以下网址的许可:
http://google.com/
http://dlc0421.googlepages.com/

点击Access右面的[Add]按钮,设定Access。







config.xml
<?xml version="1.0" encoding="UTF-8"?>
<widget id="PhotoSample_1279489457855" version="1.0" width="280" height="230">
    <content src="index.html" type="text/html"/>
    <name>Slideshow</name>
    <description>The sample of Slideshow</description>
    <author url="http://www.gclue.jp">GClue</author>
    <icon src="icon.png"/>
    <license>(C) 2010 GClue KK</license>
    <access uri="http://google.com/" subdomains="true"/>
    <access uri="http://dlc0421.googlepages.com/" subdomains="false"/>
</widget>

index.html文件的编辑

将刚才从Google Playground复制的源代码,原封不动的复制到里面。 

index.html
<!--
  copyright (c) 2009 Google inc.

  You are free to copy and use this sample.
  License can be found here: http://code.google.com/apis/ajaxsearch/faq/#license
-->

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
    <title>Slideshow</title>
    <!-- Scripts for the slideshow -->
    <script src="http://www.google.com/jsapi" type="text/javascript"></script>
    <script src="http://www.google.com/uds/solutions/slideshow/gfslideshow.js"
            type="text/javascript"></script>
    <style type="text/css">
      #picasaSlideshow {
        width:  250px;
        height200px;
        margin-bottom40px;
        padding5px;
      }
    </style>
    <script type="text/javascript">
    /*
    *  How to make a slideshow with a photo feed using our custom control.
    *  To see the options, go here or click the docs link in the titlebar:
    *  http://www.google.com/uds/solutions/slideshow/index.html
    */
    
    google.load("feeds""1");
    
    function OnLoad({
      var feed  "http://dlc0421.googlepages.com/gfss.rss";
      var options {
        displayTime:2000,
        transistionTime:600,
        scaleImages:true,
        fullControlPanel true
      };
      var ss new GFslideShow(feed"picasaSlideshow"options);
    }
    
    google.setOnLoadCallback(OnLoad);
    </script>
  </head>
  <body style="font-family: Arial, sans-serif;border: 0 none;">
  <div id="picasaSlideshow" class="gslideshow"><div class="feed-loading">Loading...</div></div>
  </body>
</html>

Packaging

接下来将进行packaging。在Eclipse里,选择[Droidget]-[Packaging]

通过USB传送到手机

通过USB接口,将开发用的电脑和手机进行连接,从Eclipse里选择[Droidget]-[Packaging Install]

通过网络传送到手机

为了将完成的FoursquareSample.wgt通过网络传送到手机里,我们需要新建一个下载用的文件download.html。

Download.html
<html>
<head>
    <title>Download</title>
</head>
<body>
    <a href="droidget://www.example.com/SlideshowSample.wgt">SlideshowSample</a><br>
</body>
</html>


运行结果



※ 本教程使用的图片资源是KDDI/au的IS01的待机画面。


Comments