PhoneGap的web视图 - 显示的联系人列表为Android只有 [英] Phonegap Webview - Show contacts list for Android Only

查看:147
本文介绍了PhoneGap的web视图 - 显示的联系人列表为Android只有的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经安装和我的Eclipse与Android的SDK一起安装环境PhoneGap的。一切似乎都工作正常,当我安装额外插件的PhoneGap [https://github.com/phonegap/phonegap-plugins/tree/master/Android/ContactView]有看我的联系人列表中的目标时除外。


这里是指令:

https://github.com/phonegap/phonegap-plugins/树/主/ Android版/ ContactView


现在我怎么拉列表进入我的索引文件下的资产/ WWW

帮助请


下面是我的索引文件:

 <!DOCTYPE HTML>
< HTML和GT;
  < HEAD>
    < META NAME =视CONTENT =WIDTH = 320;用户可扩展性=无/>
    < META HTTP-EQUIV =内容类型内容=text / html的;字符集= UTF-8>
    <标题>的PhoneGap演示使用jQuery Mobile< /标题>
      <链接rel =stylesheet属性HREF =jquery.mobile / jquery.mobile-1.0.css类型=文/ CSS/>
      <链接rel =stylesheet属性HREF =pgandjqm的风格,override.css类型=文/ CSS/>
      <脚本类型=文/ JavaScript的字符集=utf-8SRC =jquery.mobile / jQuery的-1.6.4.min>< / SCRIPT>
      <脚本类型=文/ JavaScript的字符集=utf-8SRC =PhoneGap的-1.3.0.js>< / SCRIPT>
      <脚本类型=文/ JavaScript的字符集=utf-8SRC =jquery.mobile / jquery.mobile-1.0.js>< / SCRIPT>
      <脚本类型=文/ JavaScript的字符集=utf-8SRC =main.js>< / SCRIPT>
      <脚本类型=文/ JavaScript的字符集=utf-8SRC =calllog.js>< / SCRIPT>    < /头>
  <身体的onload =的init();>
    < D​​IV数据角色=页面数据主题=B>
    < D​​IV数据角色=头>
        < H1>欢迎恒星< / H1>
    < / DIV>
    < D​​IV数据角色=内容><脚本类型=文/ JavaScript的> window.plugins.CallLog.list('所有',successCallBack,failCallBack);< / SCRIPT>< / DIV>
    < D​​IV数据角色=内容>< A HREF =电话:411数据角色=按钮>调用411 LT; / A>
    < D​​IV数据角色=按钮的onclick =window.plugins.CallLog.list('所有',successCallBack,failCallBack);>提示音及LT; / DIV>
    < D​​IV数据角色=按钮的onclick =嘟();>提示音及LT; / DIV>    < D​​IV ID =视口级=视口风格=显示:无;>
      < IMG风格=宽度:60像素,高度:60像素ID =test_imgSRC =/>
    < / DIV>
    < / DIV><! - 结束JQM内容 - >
    < D​​IV数据角色=页脚>
        < H1>感谢被周围< / H1>
    < / DIV>  < /身体GT;
< / HTML>


解决方案

下面的文件应该使其工作。顺便说一句,我不知道什么在你calllog.js,但肯定需要一个ContactView.js index.html中。请参见下面的文件和应用程序完全运行的截图:

index.html的

 <!DOCTYPE HTML>
< HTML和GT;
  < HEAD>
    < META NAME =视CONTENT =WIDTH = 320;用户可扩展性=无/>
    < META HTTP-EQUIV =内容类型内容=text / html的;字符集= UTF-8>
    <标题>的PhoneGap演示使用jQuery Mobile< /标题>
      <链接rel =stylesheet属性HREF =jquery.mobile / jquery.mobile-1.0.css类型=文/ CSS/>
      <链接rel =stylesheet属性HREF =pgandjqm的风格,override.css类型=文/ CSS/>
      <脚本类型=文/ JavaScript的字符集=utf-8SRC =jquery.mobile / jQuery的-1.6.4.min>< / SCRIPT>
      <脚本类型=文/ JavaScript的字符集=utf-8SRC =PhoneGap的-1.3.0.js>< / SCRIPT>
      <脚本类型=文/ JavaScript的字符集=utf-8SRC =jquery.mobile / jquery.mobile-1.0.js>< / SCRIPT>
      <脚本类型=文/ JavaScript的字符集=utf-8SRC =main.js>< / SCRIPT>
      <脚本类型=文/ JavaScript的字符集=utf-8SRC =ContactView.js>< / SCRIPT>
      <脚本类型=文/ JavaScript的字符集=utf-8>
      VAR successCallBack =功能(参数){
        警报(JSON.stringify(参数));
        };
      VAR failCallBack =功能(参数){
        警报(JSON.stringify(参数));
        };
      < / SCRIPT>    < /头>
  <身体的onload =的init();>
    < D​​IV数据角色=页面数据主题=B>
    < D​​IV数据角色=头>
        < H1>欢迎恒星< / H1>
    < / DIV>    < D​​IV数据角色=内容>< A HREF =电话:411数据角色=按钮>调用411 LT; / A>
    < D​​IV数据角色=按钮的onclick =window.plugins.ContactView.show('所有',successCallBack,failCallBack);>提示音及LT; / DIV>
    < D​​IV数据角色=按钮的onclick =嘟();>提示音及LT; / DIV>    < D​​IV ID =视口级=视口风格=显示:无;>
      < IMG风格=宽度:60像素,高度:60像素ID =test_imgSRC =/>
    < / DIV>
    < / DIV><! - 结束JQM内容 - >
    < D​​IV数据角色=页脚>
        < H1>感谢被周围< / H1>
    < / DIV>  < /身体GT;
< / HTML>

ContactView.js

  VAR ContactView =功能(){};ContactView.prototype.show =功能(CMD,successCallback,failCallback){    函数成功(参数){
        successCallback(参数);
    }    功能失效(参数){
        failCallback(参数);
    }    返回PhoneGap.exec(功能(参数){
        成功(参数);
    },功能(参数){
        失败(参数);
    },'ContactView','',[]);
};/ **
 *负荷ChildBrowser
 * /
PhoneGap.addConstructor(函数(){
    PhoneGap.addPlugin(ContactView,新ContactView());
});

此外,RES / XML / plugins.xml需要添加以下行:

 <插件名称=ContactViewVALUE =com.rearden.ContactView/>

接下来是显示的目录结构的截图,更改的文件并运行应用程序:

I have setup and installed Phonegap on my Eclipse environment together with Android SDKs. Everything seems to be working fine except when I install additional phonegap plugin [https://github.com/phonegap/phonegap-plugins/tree/master/Android/ContactView] with the aim of viewing my contacts list.


Here are the instruction:

https://github.com/phonegap/phonegap-plugins/tree/master/Android/ContactView


now how do I pull the list into my index file under assets/www

Help Please


Here is my index file:

<!DOCTYPE HTML>
<html>
  <head>
    <meta name="viewport" content="width=320; user-scalable=no" />
    <meta http-equiv="Content-type" content="text/html; charset=utf-8">
    <title>PhoneGap Demo With JQuery Mobile</title>
      <link rel="stylesheet" href="jquery.mobile/jquery.mobile-1.0.css" type="text/css"/>
      <link rel="stylesheet" href="pgandjqm-style-override.css" type="text/css"/>
      <script type="text/javascript" charset="utf-8" src="jquery.mobile/jquery-1.6.4.min"></script>
      <script type="text/javascript" charset="utf-8" src="phonegap-1.3.0.js"></script>
      <script type="text/javascript" charset="utf-8" src="jquery.mobile/jquery.mobile-1.0.js"></script>
      <script type="text/javascript" charset="utf-8" src="main.js"></script>
      <script type="text/javascript" charset="utf-8" src="calllog.js"></script>

    </head>
  <body onload="init();">
    <div data-role="page" data-theme="b">
    <div data-role="header">
        <h1>Welcome to Stellar</h1> 
    </div>
    <div data-role="content"><script type="text/javascript"> window.plugins.CallLog.list('all', successCallBack, failCallBack);</script></div>
    <div data-role="content"><a href="tel:411" data-role="button">Call 411</a>
    <div data-role="button" onclick="window.plugins.CallLog.list('all', successCallBack, failCallBack);">Beep</div>
    <div data-role="button" onclick="beep();">Beep</div>

    <div id="viewport" class="viewport" style="display:none;">       
      <img style="width:60px;height:60px" id="test_img" src="" />
    </div> 
    </div><!-- end jqm content -->
    <div data-role="footer">
        <h1>Thanks for being around</h1>
    </div>

  </body>
</html>

解决方案

The files below should make it work. BTW, I'm not sure what's in your calllog.js, but there definitely needs to be a ContactView.js in index.html. See the following files and screenshot of the full app running:

index.html

<!DOCTYPE HTML>
<html>
  <head>
    <meta name="viewport" content="width=320; user-scalable=no" />
    <meta http-equiv="Content-type" content="text/html; charset=utf-8">
    <title>PhoneGap Demo With JQuery Mobile</title>
      <link rel="stylesheet" href="jquery.mobile/jquery.mobile-1.0.css" type="text/css"/>
      <link rel="stylesheet" href="pgandjqm-style-override.css" type="text/css"/>
      <script type="text/javascript" charset="utf-8" src="jquery.mobile/jquery-1.6.4.min"></script>
      <script type="text/javascript" charset="utf-8" src="phonegap-1.3.0.js"></script>
      <script type="text/javascript" charset="utf-8" src="jquery.mobile/jquery.mobile-1.0.js"></script>
      <script type="text/javascript" charset="utf-8" src="main.js"></script>
      <script type="text/javascript" charset="utf-8" src="ContactView.js"></script>
      <script type="text/javascript" charset="utf-8"> 
      var successCallBack = function(args) {
        alert (JSON.stringify(args));
        };
      var failCallBack = function(args) {
        alert (JSON.stringify(args));
        };
      </script>

    </head>
  <body onload="init();">
    <div data-role="page" data-theme="b">
    <div data-role="header">
        <h1>Welcome to Stellar</h1> 
    </div>

    <div data-role="content"><a href="tel:411" data-role="button">Call 411</a>
    <div data-role="button" onclick="window.plugins.ContactView.show('all', successCallBack, failCallBack);">Beep</div>
    <div data-role="button" onclick="beep();">Beep</div>

    <div id="viewport" class="viewport" style="display:none;">       
      <img style="width:60px;height:60px" id="test_img" src="" />
    </div> 
    </div><!-- end jqm content -->
    <div data-role="footer">
        <h1>Thanks for being around</h1>
    </div>

  </body>
</html>

ContactView.js

var ContactView = function() {};

ContactView.prototype.show = function(cmd, successCallback, failCallback) {

    function success(args) {
        successCallback(args);
    }

    function fail(args) {
        failCallback(args);
    }

    return PhoneGap.exec(function(args) {
        success(args);
    }, function(args) {
        fail(args);
    }, 'ContactView', '', []);
};

/**
 * Load ChildBrowser
 */
PhoneGap.addConstructor(function() {
    PhoneGap.addPlugin("ContactView", new ContactView());
});

Also, res/xml/plugins.xml needs the following line added:

  <plugin name="ContactView" value="com.rearden.ContactView"/>

Next is the screenshot showing the directory structure, changed files and running app:

这篇关于PhoneGap的web视图 - 显示的联系人列表为Android只有的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆