2011-12-28 43 views
1

我已經在我的Eclipse環境中與Android SDK一起安裝並安裝了Phonegap。除了當我安裝額外的phonegap插件[https://github.com/phonegap/phonegap-plugins/tree/master/Android/ContactView]以查看我的聯繫人列表時,一切似乎都正常工作。Phonegap Webview - 僅顯示Android的聯繫人列表


這裏是指令:

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


現在我怎麼拉列表進入下資產/ WWW我的索引文件

幫助請


這裏是我的索引文件:

<!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> 

回答

0

下面的文件應該使其工作。順便說一句,我不知道你的calllog.js中有什麼,但肯定需要在index.html中有一個ContactView.js。查看完整的應用程序運行的下列文件和截圖:

的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()); 
}); 

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

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

下面是顯示目錄結構,更改的文件和正在運行的應用程序的屏幕截圖:

Screen shot of running app

相關問題