我刚刚安装了phonegap并且是我的新手。我在android文件夹下导入了该示例并运行它,它似乎正确地显示了底层文件。但是,如何导入我的html / js文件。我试图在线查找,但到目前为止没有运气。如何在phonegap中为webview创建项目,同时导入我的js / html文件。我还需要在android中编写相同的代码或手机缺口为我做的一切?
答案 0 :(得分:0)
您必须将html,js和css文件放在assets文件夹中。
在主要活动中,您可以按如下方式引用它们:
super.loadUrl("file:///android_asset/www/index.html");
根据PhoneGap Documentation - Getting Started with Android
修改强>
关于格式化并使其适合屏幕将取决于您对html,css和js文件的处理方式。例如,这是一个html文件,它独立于屏幕方向和屏幕尺寸适合屏幕:
<!DOCTYPE html>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="format-detection" content="telephone=no" />
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
<title>Hello World</title>
</head>
<body>
<h1>Apache Cordova</h1>
<div>Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Typi non habent claritatem insitam; est usus legentis in iis qui facit eorum claritatem. Investigationes demonstraverunt lectores legere me lius quod ii legunt saepius. Claritas est etiam processus dynamicus, qui sequitur mutationem consuetudium lectorum. Mirum est notare quam littera gothica, quam nunc putamus parum claram, anteposuerit litterarum formas humanitatis per seacula quarta decima et quinta decima. Eodem modo typi, qui nunc nobis videntur parum clari, fiant sollemnes in futurum.</div>
</body>
</html>
我所做的是总结原始的cordova的html,它完全适用于应用程序。
有关格式化的更多信息,请在应用启动并运行后参考网页设计问题,而不是PhoneGap。