Android导航组件-在包含的模块图之间导航

时间:2019-08-19 09:22:58

标签: android android-architecture-components android-navigation android-architecture-navigation

我有一个包含3个模块的单独活动应用程序- <style> #editor { height: 120px; } #codeOutput { height: 120px; } </style> <!-- scripts libraries : jquery, bootstrap et skulpt --> <script src=".../jquery/3.3.1/jquery.min.js"></script> <script src=".../js/bootstrap.min.js"></script> <script src=".../js/skulpt.min.js"></script> <script src=".../js/skulpt-stdlib.js"></script> <script> function clearAceCode() { editor.setValue(""); } </script> <script type="text/javascript"> function outf(text) { var mypre = document.getElementById("codeOutput"); mypre.innerHTML = mypre.innerHTML + text; } function builtinRead(x) { if (Sk.builtinFiles === undefined || Sk.builtinFiles["files"][x] === undefined) throw "Fichier introuvable: '" + x + "'"; return Sk.builtinFiles["files"][x]; } function runit() { var prog = (editor.getValue()); var mypre = document.getElementById("codeOutput"); mypre.innerHTML = ''; Sk.pre = "codeOutput"; Sk.configure({output:outf, read:builtinRead}); var myPromise = Sk.misceval.asyncToPromise(function() { return Sk.importMainWithBody("<stdin>", false, prog, true); }); myPromise.then(function(mod) { console.log('success'); }, function(err) { console.log(err.toString()); }); } </script> </head> <body> <div class="container"> <h2> </h2> <div class="col-sm-8"> <h4>Fenêtre d'édition</h4> <div id="editor"></div> <script src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.1/ace.js"></script> <script> var editor = ace.edit("editor"); document.getElementById('editor').style.fontSize='14px'; editor.setTheme("ace/theme/textmate"); editor.getSession().setMode("ace/mode/python"); code = "def poids(masse): \n return masse*9.81 \n\nprint(poids(56))\n"; editor.setValue(code); </script> <button class="btn btn-default" onclick="runit()">Exécuter</button> <button class="btn btn-default" onclick="clearAceCode()">Effacer</button> <button class="btn btn-default" onclick="editor.setValue(code)">Restaurer</button> <h4>Sortie :</h4> <textarea id="codeOutput" style="width:100%" ></textarea> </div> </div> </div> </body> applist。我的活动在detail模块中,它仅托管app。所有模块都有自己的导航图。 NavHostFragment的起点需要一个长参数。 detail的图表成为其他因素的父母:

app

但是默认情况下,它禁止在编辑器上向包含的图形添加动作:

ss1

我可以在xml文件中添加一个全局操作,然后将其显示在编辑器中:

<?xml version="1.0" encoding="utf-8"?>
<navigation
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/nav_main"
    app:startDestination="@id/nav_list">

    <include app:graph="@navigation/nav_list" />
    <include app:graph="@navigation/nav_detail" />
</navigation>

我不想使用全局操作,而是添加适当的<?xml version="1.0" encoding="utf-8"?> <navigation xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:id="@+id/nav_main" app:startDestination="@id/nav_list"> <include app:graph="@navigation/nav_list" /> <include app:graph="@navigation/nav_detail" /> <action android:id="@+id/action_global_detailFragment" app:destination="@id/nav_detail" /> </navigation> 来封装导航模式。嵌套图已经包含其导航逻辑,仅需要输入即可作为入口点。我不确定是否不支持此功能,是否缺少某些内容?为什么不呢?在两个或多个包含的图形之间导航的方式是什么?

0 个答案:

没有答案