Hybrid   发布时间:2022-05-02  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了Hybrid App 开发初探:使用 WebView 装载页面大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
@H_772_0@
@H_772_0@

http://www.cnblogs.com/lhb25/archive/2012/07/16/hybrid-app-developement.html

Hybrid App 是混合模式应用的简称,兼具 Native App 和 Web App 两种模式应用的优势,开发成本低,拥有 Web 技术跨平台特性。目前大家所知道的基于中间件的移动开发框架都是采用的 Hybrid 开发模式,例如国外的 PhoneGap、Titanium、Sencha,还有国内的 AppCan、Rexsee 等等。Hybrid App 开发模式正在被越来越多的公司和开发者所认同,相信将来会成为主流的移动应用开发模式。

  

Hybrid App 开发初探:使用 WebView 装载页面

 

  Hybrid App 融合 Web App 的原理就是嵌入一个WebView组件,可以在这个组件中载入页面,相当于内嵌的浏览器,代码如下:

?
@H_489_33@ 1 @H_616_35@ 2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import  android.app.Activity;
android.os.bundle;
android.webkit.WebSetTings;
android.webkit.WebView;
 
public  class  AActivity extends  Activity{
     
     @Override
     void  onCreate(Bundle savedInstanceStatE) {
         super .onCreate(savedInstanceStatE);
         // 创建WebView
         WebView webView= new  WebView( this );
// 切换到内容视图
setContentView(webView);
// 获取WebView配置
WebSetTings ws = webView.getSetTings();
// 启用JavaScript
ws.setJavaScriptEnabled( true );
// 载入assets目录下的一个页面
     }
}

  还有另一种引入方式是在布局文件添加 WebView 组件,代码如下:

13
<? xml  version = "1.0"  encoding "utf-8" ?>
< LinearLayout  xmlns:android "http://schemas.android.com/apk/res/android"
     android:orientation "vertical"
android:layout_width "fill_parent"
android:layout_height "fill_parent" >
     
     WebView 
         "fill_parent"
"wrap_content"
android:id "@+id/webview"
</ LinearLayout >

大佬总结

以上是大佬教程为你收集整理的Hybrid App 开发初探:使用 WebView 装载页面全部内容,希望文章能够帮你解决Hybrid App 开发初探:使用 WebView 装载页面所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
猜你在找的Hybrid相关文章