zoukankan      html  css  js  c++  java
  • cordova2.2对于CordovaWebView的配置

    Java文件配置:官方说明不够清晰

    package org.apache.cordova.example;
    
    import java.util.concurrent.ExecutorService;
    import java.util.concurrent.Executors;
    
    import android.app.Activity;
    import android.content.Context;
    import android.content.Intent;
    import android.os.Bundle;
    import org.apache.cordova.*;
    import org.apache.cordova.api.CordovaInterface;
    import org.apache.cordova.api.CordovaPlugin;
    
    public class cordovaExample extends Activity implements CordovaInterface{  
        
        CordovaWebView cordovaWebView;  
          
        private final ExecutorService threadPool =Executors.newCachedThreadPool();  
          
        @Override  
        public void onCreate(Bundle savedInstanceState) {  
            super.onCreate(savedInstanceState);  
              
            setContentView(R.layout.main);  
              
            cordovaWebView=(CordovaWebView) findViewById(R.id.tutoriaView);  
              
            cordovaWebView.loadUrl("file:///android_asset/www/index.html");  
        }  
      
        @Override  
        public void cancelLoadUrl() {  
              
        }  
      
        @Override  
        public Activity getActivity() {  
            return this;  
        }  
      
        @Override  
        public Context getContext() {  
            return this.getContext();  
        }  
      
        @Override  
        public ExecutorService getThreadPool() {  
            return threadPool;  
        }  
      
        @Override  
        public Object onMessage(String string, Object object) {  
            return null;  
        }  
      
        @Override  
        public void setActivityResultCallback(CordovaPlugin cordovaPlugin) {  
              
        }  
      
        @Override  
        public void startActivityForResult(CordovaPlugin plugin, Intent intent, int i) {  
              
        }    
    
    }  

    R.layout.main文件配置,不明白官方文档为什么写成res/xml

    <?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"
        >
    
    <org.apache.cordova.CordovaWebView
        android:id="@+id/tutoriaView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>
    
    </LinearLayout>  
    从容是一种态度。
  • 相关阅读:
    mybatis学习坑路
    一文理解class.getClassLoader().getResourceAsStream(file)和class.getResourceAsStream(file)区别
    servlet的坑
    class.getResource()方法的更新 坑
    utf8和字节数组的转换
    finally模块的各种情况
    C++ 动态对象数组的知识总结
    Notepad++正则表达式语法
    诸子百家55句
    给初始化为NULL的结构体指针赋值报错问题
  • 原文地址:https://www.cnblogs.com/yume2015/p/3103578.html
Copyright © 2011-2022 走看看