aaaaaaaa
aaaaaaaa
  • 发布:2015-05-27 15:45
  • 更新:2015-05-27 16:16
  • 阅读:2358

点击要打开的页面后不显示相应的页面。

分类:MUI

我用以下方式打开了index.html页面,在index.html页面里点击列表打开其它页面时后台没报错要打开的页面也没显示。

public class MainActivity extends Activity {  

    @Override  
    protected void onCreate(Bundle savedInstanceState) {  
        super.onCreate(savedInstanceState);  
        //setContentView(R.layout.activity_main);  
        Intent intent = null;  
        intent = new Intent(MainActivity.this, SDK_WebView.class);  
        this.startActivity(intent);  
    }  
..............................  
.............................  

public class SDK_WebView extends Activity{  

    boolean doHardAcc = true;  
    EntryProxy mEntryProxy = null;  
    @Override  
    public void onCreate(Bundle savedInstanceState) {  
        super.onCreate(savedInstanceState);  
        requestWindowFeature(Window.FEATURE_NO_TITLE);  
        if(mEntryProxy == null){  
            FrameLayout rootView = new FrameLayout(this);  
            WebviewMode wm = new WebviewMode(this,rootView);  
             mEntryProxy = EntryProxy.init(this,wm);  
             mEntryProxy.onCreate(savedInstanceState,SDK.IntegratedMode.WEBVIEW,null);  
             setContentView(rootView);  
        }  
    }  
...........................  
...........................  
...........................  

class WebviewMode implements ICoreStatusListener{  

    LinearLayout btns = null;  
    Activity activity = null;  
    ViewGroup mRootView = null;  
    public WebviewMode(Activity activity,ViewGroup rootView){  
        this.activity = activity;  
        mRootView = rootView;  
        btns = new LinearLayout(activity);  
        mRootView.setBackgroundColor(0xffffffff);  
        mRootView.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {  
            @Override  
            public void onGlobalLayout(){  
                webview.onRootViewGlobalLayout(mRootView);  
            }  

        });  
    }  

    @SuppressWarnings("deprecation")  
    @Override  
    public void onCoreInitEnd(ICore coreHandler) {  
//      SDK.initSDK(coreHandler);  
        //注册扩展的Feature    
        //1,featureName 为特征名称  
        //2, className  为处理扩展Feature的接收类全名称  
        //3, content  为扩展Feature而创建的js代码,代码中必须使用 plus.bridge.execSync(featureName,actionName,[arguments])或plus.bridge.exec(featureName,actionName,[arguments])与native层进行数据交互  
        SDK.registerJsApi(featureName, className, content);  
        //创建默认webapp,赋值appid  
        String url = "file:///android_asset/apps/HelloH5/www/index.html";  
        showWebview("test1", url, new FrameLayout.LayoutParams(-1,800,0));  
        //SDK.closeWebView(webview);  
    }  

.................  
.................  
.................

后台显示内容如下:
05-27 15:41:59.129: D/adawebview(7360): webviewimp=<url=file:///android_asset/apps/HelloH5/www/examples/template.html>;<hashcode=1094348600>;exec evalJS=typeof mui!=='undefined'&&mui.receive('updateHeader','{"title":"右侧带数字角标","showMenu":false}')
05-27 15:41:59.139: D/webview(7360): reload loadUrl url=file:///android_asset/apps/HelloH5/www/examples/tableviews-with-badges.html
05-27 15:41:59.139: D/View_Visible_Path(7360): AdaFrameView.setVisible pVisibletrue <UUID=NWindow31432709356538>;<url=file:///android_asset/apps/HelloH5/www/examples/template.html>;<hashcode=1094348600>
05-27 15:41:59.149: D/Map_Path(7360): sortNWindowByZIndex beign
05-27 15:41:59.159: D/Animation_Path(7360): showWindow<UUID=NWindow31432709356538>;<url=file:///android_asset/apps/HelloH5/www/examples/template.html>;<hashcode=1094348600>
05-27 15:41:59.169: D/Animation_Path(7360): onWillDoAnimation <UUID=NWindow31432709356538>;<url=file:///android_asset/apps/HelloH5/www/examples/template.html>;<hashcode=1094348600>
05-27 15:41:59.169: D/DCloud_LOG(7360): AdaFrameView.dispatchFrameViewEvents type=show_animation_end;args=null
05-27 15:41:59.169: D/DCloud_LOG(7360): execCallback pEventType=show;
05-27 15:41:59.169: D/Animation_Path(7360): onDoneAnimation <UUID=NWindow31432709356538>;<url=file:///android_asset/apps/HelloH5/www/examples/template.html>;<hashcode=1094348600>
05-27 15:41:59.169: D/Animation_Path(7360): on_Done_Animation 动画完后存在窗口出栈;<UUID=NWindow31432709356538>;<url=file:///android_asset/apps/HelloH5/www/examples/template.html>;<hashcode=1094348600>
05-27 15:41:59.179: D/Animation_Path(7360): removeFrameViewFromViewStack DoAnimation Frame=<UUID=NWindow31432709356538>;<url=file:///android_asset/apps/HelloH5/www/examples/template.html>;<hashcode=1094348600>;Will PopFrames=[<UUID=1094145456>;<url=file:///android_asset/apps/HelloH5/www/index.html>;<hashcode=1094162616>, <UUID=NWindow51432709354807>;<url=file:///android_asset/apps/HelloH5/www/index-menu.html>;<hashcode=1093482568>]
05-27 15:41:59.179: D/Animation_Path(7360): onShowAnimationEnd;<UUID=NWindow31432709356538>;<url=file:///android_asset/apps/HelloH5/www/examples/template.html>;<hashcode=1094348600>
05-27 15:41:59.179: D/View_Visible_Path(7360): show <UUID=NWindow31432709356538>;<url=file:///android_asset/apps/HelloH5/www/examples/template.html>;<hashcode=1094348600>;webview_name=default-main
05-27 15:41:59.199: D/webview(7360): onPageStarted url=file:///android_asset/apps/HelloH5/www/examples/tableviews-with-badges.html
05-27 15:41:59.199: D/DCloud_LOG(7360): AdaFrameView.dispatchFrameViewEvents type=loading;args=<UUID=NWindow51432709356547>;<url=file:///android_asset/apps/HelloH5/www/examples/tableviews-with-badges.html>;<hashcode=1092231632>
05-27 15:41:59.199: D/DCloud_LOG(7360): execCallback pEventType=loading;
05-27 15:41:59.249: I/webview(7360): onReceivedTitle title=Hello MUI
05-27 15:41:59.409: I/webview(7360): onPageFinished url=file:///android_asset/apps/HelloH5/www/examples/tableviews-with-badges.html
05-27 15:41:59.409: I/webview(7360): onPageFinished loadAllJSContent url=file:///android_asset/apps/HelloH5/www/examples/tableviews-with-badges.html
05-27 15:41:59.439: D/DCloud_LOG(7360): AdaFrameView.dispatchFrameViewEvents type=loaded;args=<UUID=NWindow51432709356547>;<url=file:///android_asset/apps/HelloH5/www/examples/tableviews-with-badges.html>;<hashcode=1092231632>
05-27 15:41:59.439: D/Main_Path(7360): EVENTS_LOADED mUrl=
05-27 15:41:59.439: D/DCloud_LOG(7360): execCallback pEventType=loaded;
05-27 15:41:59.449: D/ReceiveJSValue(7360): jscallnative js=["number",1]
05-27 15:41:59.459: D/webview(7360): completeLoadJs tag=onPageFinished url=file:///android_asset/apps/HelloH5/www/examples/tableviews-with-badges.html
05-27 15:41:59.469: D/ReceiveJSValue(7360): jscallnative js=["number",1]
05-27 15:41:59.479: D/dalvikvm(7360): GC_CONCURRENT freed 843K, 20% free 9548K/11911K, paused 1ms+3ms
05-27 15:41:59.479: D/webview(7360): completeLoadJs tag=onPageFinished url=file:///android_asset/apps/HelloH5/www/examples/tableviews-with-badges.html
05-27 15:41:59.719: D/View_Visible_Path(7360): AdaFrameView.setVisible pVisibletrue <UUID=NWindow51432709356547>;<url=file:///android_asset/apps/HelloH5/www/examples/tableviews-with-badges.html>;<hashcode=1092231632>
05-27 15:41:59.729: D/Map_Path(7360): sortNWindowByZIndex beign
05-27 15:41:59.729: D/Animation_Path(7360): showWindow<UUID=NWindow51432709356547>;<url=file:///android_asset/apps/HelloH5/www/examples/tableviews-with-badges.html>;<hashcode=1092231632>
05-27 15:41:59.729: D/Animation_Path(7360): onWillDoAnimation <UUID=NWindow51432709356547>;<url=file:///android_asset/apps/HelloH5/www/examples/tableviews-with-badges.html>;<hashcode=1092231632>
05-27 15:41:59.729: D/DCloud_LOG(7360): AdaFrameView.dispatchFrameViewEvents type=show_animation_end;args=null
05-27 15:41:59.729: D/DCloud_LOG(7360): execCallback pEventType=show;
05-27 15:41:59.739: D/Animation_Path(7360): onDoneAnimation <UUID=NWindow51432709356547>;<url=file:///android_asset/apps/HelloH5/www/examples/tableviews-with-badges.html>;<hashcode=1092231632>
05-27 15:41:59.739: D/Animation_Path(7360): onShowAnimationEnd;<UUID=NWindow51432709356547>;<url=file:///android_asset/apps/HelloH5/www/examples/tableviews-with-badges.html>;<hashcode=1092231632>
05-27 15:41:59.739: D/View_Visible_Path(7360): show <UUID=NWindow51432709356547>;<url=file:///android_asset/apps/HelloH5/www/examples/tableviews-with-badges.html>;<hashcode=1092231632>;webview_name=default-sub

2015-05-27 15:45 负责人:无 分享
已邀请:
aaaaaaaa

aaaaaaaa (作者)

index.html代码

<!DOCTYPE html>  
<html>  

    <head>  
        <meta charset="utf-8">  
        <title>Hello MUI</title>  
        <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1, user-scalable=no">  
        <meta name="apple-mobile-web-app-capable" content="yes">  
        <meta name="apple-mobile-web-app-status-bar-style" content="black">  

        <link rel="stylesheet" href="css/mui.min.css">  
    </head>  

    <body>  
        <header class="mui-bar mui-bar-nav">  
            <a class="mui-icon mui-icon-bars mui-pull-left"></a>  
            <a id="info" class="mui-icon mui-icon-info-filled mui-pull-right" style="color: #999;"></a>  
            <h1 class="mui-title">Hello mui</h1>  
        </header>  
        <script src="js/mui.min.js"></script>  
        <script src="js/update.js" type="text/javascript" charset="utf-8"></script>  
        <script>  
            var menu = null,  
                main = null;  
            var showMenu = false;  
            mui.init({  
                swipeBack: false,  
                statusBarBackground: '#f7f7f7',  
                gestureConfig:{  
                    doubletap:true  
                },  
                subpages: [{  
                    id: 'list',  
                    url: 'list.html',  
                    styles: {  
                        top: '45px',  
                        bottom: 0,  
                        bounce: 'vertical'  
                    }  
                }]  
            });  

            mui.plusReady(function() {  

                if (mui.os.android) {  
                    plus.screen.lockOrientation("portrait-primary");  
                }  
                main = plus.webview.currentWebview();  
                main.addEventListener('maskClick', closeMenu);  
                //处理侧滑导航,为了避免和子页面初始化等竞争资源,延迟加载侧滑页面;  
                setTimeout(function() {  
                    menu = mui.preload({  
                        id: 'index-menu',  
                        url: 'index-menu.html',  
                        styles: {  
                            left: 0,  
                            width: '70%',  
                            zindex: -1  
                        },  
                        show: {  
                            aniShow: 'none'  
                        }  
                    });  
                }, 200);  
            });  

            /**  
             * 显示侧滑菜单  
             */  
            function openMenu() {  
                if (!showMenu) {  
                    //侧滑菜单处于隐藏状态,则立即显示出来;  
                    menu.show('none', 0, function() {  
                        //主窗体开始侧滑并显示遮罩  
                        main.setStyle({  
                            mask: 'rgba(0,0,0,0.4)',  
                            left: '70%',  
                            transition: {  
                                duration: 150  
                            }  
                        });  
                        showMenu = true;  
                    });  
                }  
            }  
            /**  
             * 关闭菜单  
             */  
            function closeMenu() {  
                if (showMenu) {  
                    //关闭遮罩;  
                    //主窗体开始侧滑;  
                    main.setStyle({  
                        mask: 'none',  
                        left: '0',  
                        transition: {  
                            duration: 200  
                        }  
                    });  
                    showMenu = false;  
                    //等动画结束后,隐藏菜单webview,节省资源;  
                    setTimeout(function() {  
                        menu.hide();  
                    }, 300);  
                }  
            }  
                //点击左上角侧滑图标,打开侧滑菜单;  
            document.querySelector('.mui-icon-bars').addEventListener('tap', function(e) {  
                if (showMenu) {  
                    closeMenu();  
                } else {  
                    openMenu();  
                }  
            });  
            //敲击顶部导航,内容区回到顶部  
            document.querySelector('header').addEventListener('doubletap',function () {  
                main.children()[0].evalJS('mui.scrollTo(0, 100)');  
            });  
             //主界面向右滑动,若菜单未显示,则显示菜单;否则不做任何操作  
            window.addEventListener("swiperight", openMenu);  
             //主界面向左滑动,若菜单已显示,则关闭菜单;否则,不做任何操作;  
            window.addEventListener("swipeleft", closeMenu);  
             //侧滑菜单触发关闭菜单命令  
            window.addEventListener("menu:close", closeMenu);  
            window.addEventListener("menu:open", openMenu);  

             //重写mui.menu方法,Android版本menu按键按下可自动打开、关闭侧滑菜单;  
            mui.menu = function() {  
                if (showMenu) {  
                    closeMenu();  
                } else {  
                    openMenu();  
                }  
            }  

             //处理右上角关于图标的点击事件;  
            var subWebview = null,  
                template = null;  
            document.getElementById('info').addEventListener('tap', function() {  
                if (subWebview == null) {  
                    //获取共用父窗体  
                    template = plus.webview.getWebviewById("default-main");  
                }  
                if(template){  
                    subWebview = template.children()[0];      
                    subWebview.loadURL('examples/info.html');  
                    //修改共用父模板的标题  
                    mui.fire(template, 'updateHeader', {  
                        title: '关于',  
                        showMenu: false  
                    });  
                    template.show('slide-in-right', 150);  
                }  
            });  

             //首页返回键处理  
             //处理逻辑:1秒内,连续两次按返回键,则退出应用;  
            var first = null;  
            mui.back = function() {  
                if (showMenu) {  
                    closeMenu();  
                } else {  
                    //首次按键,提示‘再按一次退出应用’  
                    if (!first) {  
                        first = new Date().getTime();  
                        mui.toast('再按一次退出应用');  
                        setTimeout(function() {  
                            first = null;  
                        }, 1000);  
                    } else {  
                        if (new Date().getTime() - first < 1000) {  
                            plus.runtime.quit();  
                        }  
                    }  
                }  
            };  
        </script>  
    </body>  

</html>
aaaaaaaa

aaaaaaaa (作者)

发现启动时控制台打印:

  • > 05-27 16:08:49.659: E/DCloud_LOG(13504): DHFile getInputStream not found file: /mnt/sdcard/Android/data/com.example.sdk5/apps/test1/www/manifest.json

我项目里没有叫test1这个名字的啊

05-27 16:08:56.389: E/nwindowmgr(13504): pActionName=execMethod;pJsArgs=["NWindow","NWindow",["NWindow51432714136202",["index-menu.html",{"scalable":false,"bounce":"","left":0,"width":"70%","zindex":-1,"name":"index-menu"},"plus61432714136202","file:///android_asset/apps/HelloH5/www/index.html",{"preload":true}]]]

05-27 16:08:56.399: W/System.err(13504): java.lang.NullPointerException
05-27 16:08:56.409: W/System.err(13504): at io.dcloud.feature.ui.e.a(UIWidgetMgr.java:398)
05-27 16:08:56.409: W/System.err(13504): at io.dcloud.feature.ui.UIFeatureImpl.execute(UIFeatureImpl.java:23)

该问题目前已经被锁定, 无法添加新回复