专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > 移动开发

phonegap底层原理学习跟研究(四)

发布时间:2010-05-30 05:28:48 文章来源:www.iduyao.cn 采编人员:星星草
phonegap底层原理学习和研究(四)

         在phonegap的android开发中主要通过WebView显示相关的本地页面。针对WebView设置的代码如下:


       //创建相关的Web容器
        this.appView = new WebView(DroidGap.this);
        this.appView.setId(100);
        //设置WebView的布局
        this.appView.setLayoutParams(new LinearLayout.LayoutParams(
                ViewGroup.LayoutParams.FILL_PARENT,
                ViewGroup.LayoutParams.FILL_PARENT,
                1.0F));
      //获取WebView的WebSetting的几个方法以便于后面通过反射注入相关的存储
        WebViewReflect.checkCompatibility();
     
        this.appView.setWebChromeClient(new GapClient(DroidGap.this));
        this.setWebViewClient(this.appView, new GapViewClient(this));

        this.appView.setInitialScale(100);
        this.appView.setVerticalScrollBarEnabled(false);
        this.appView.requestFocusFromTouch();

        // Enable JavaScript
        WebSettings settings = this.appView.getSettings();

       //启用js脚本的运行
        settings.setJavaScriptEnabled(true);
        //js是否可以打开窗体

        settings.setJavaScriptCanOpenWindowsAutomatically(true);
        settings.setLayoutAlgorithm(LayoutAlgorithm.NORMAL);

        // Enable database
        settings.setDatabaseEnabled(true);
        String databasePath = this.getApplicationContext().getDir("database", Context.MODE_PRIVATE).getPath();
        settings.setDatabasePath(databasePath);

        // Enable DOM storage
        WebViewReflect.setDomStorage(settings);
       
        // Enable built-in geolocation
        WebViewReflect.setGeolocationEnabled(settings, true);

        // Create callback server and plugin manager
        this.callbackServer = new CallbackServer();
        this.pluginManager = new PluginManager(this.appView, this);       

        // Add web view but make it invisible while loading URL
        this.appView.setVisibility(View.INVISIBLE);
        root.addView(this.appView);

友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: