gpt4 book ai didi

Navigation action/destination action cannot be found from the current destination(在当前目标中找不到导航操作/目标操作)

转载 作者:bug小助手 更新时间:2023-10-28 09:39:36 28 4
gpt4 key购买 nike



I used navigation component in my app.
I uploaded my app to firebase to make a test.
app worked normally in the most of devices, but in some devices app crashed and show the error in this image

我在我的应用程序中使用了导航组件。我把我的应用程序上传到firebase进行测试。应用程序在大多数设备中正常工作,但在某些设备中应用程序崩溃并显示此图像中的错误


enter image description here


Here's my navigation file code

这是我的导航文件代码


<navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main"
app:startDestination="@id/menuhome">


<fragment
android:id="@+id/menuhome"
android:name="com.poultry.poultryscope.HomeFragment"
android:label="Home"
tools:layout="@layout/fragment_home" >

<action
android:id="@+id/action_menuhome_to_menuDrugs"
app:destination="@id/menuDrugs" />
<action
android:id="@+id/action_menuhome_to_menudiseases"
app:destination="@id/menudiseases" />
<action
android:id="@+id/action_menuhome_to_menuDoseCalculator"
app:destination="@id/menuDoseCalculator" />
<action
android:id="@+id/action_menuhome_to_menuReferences"
app:destination="@id/menuReferences" />
</fragment>

<fragment
android:id="@+id/menudiseases"
android:name="com.poultry.poultryscope.DiseasesFragment"
android:label="@string/diseases"
tools:layout="@layout/fragment_diseases" />

<fragment
android:id="@+id/menuDrugs"
android:name="com.poultry.poultryscope.DrugsFragment"
android:label="@string/drugs"
tools:layout="@layout/fragment_drugs" />

<fragment
android:id="@+id/menuDoseCalculator"
android:name="com.poultry.poultryscope.DoseCalculatorFragment"
android:label="@string/DC"
tools:layout="@layout/fragment_dose_calculator" />

<fragment
android:id="@+id/menuReferences"
android:name="com.poultry.poultryscope.ReferencesFragment"
android:label="@string/references"
tools:layout="@layout/fragment_references" />
<fragment
android:id="@+id/menuAboutUs"
android:name="com.poultry.poultryscope.AboutFragment"
android:label="@string/about_us"
tools:layout="@layout/fragment_about" />


So why is this happening? Thank you.

为什么会这样呢?谢谢


更多回答

The route on the URL cannot be found or you do not have permission to the route (id/menuDrugs).

找不到URL上的路由,或者您没有访问该路由的权限(id/menuDrugs)。

why app worked in some devices and crashed in others

为什么APP在一些设备上运行,在另一些设备上崩溃

The account being used. Some machines the account is Admin and other not Admin. An Admin would have permission to all files while normal user would not.

正在使用的帐户。某些计算机的帐户是Admin,而其他计算机的帐户不是Admin。管理员将拥有访问所有文件的权限,而普通用户则没有。

优秀答案推荐

double click is the cause of the crash.

双击是导致崩溃的原因。


I added if condition to handle the click for each item in the menu home and the problem was solved.

我添加了IF条件来处理主菜单中每一项的点击,问题就解决了。


example for diseases click

疾病示例,点击


if (navController.getCurrentDestination().getId() == R.id.menuhome) {
navController.navigate(R.id.action_menuhome_to_menudiseases);
}

and for drugs click

对于药品,请点击


 if (navController.getCurrentDestination().getId() == R.id.menuhome) {

navController.navigate(R.id.action_menuhome_to_menuDrugs);

enter image description here


更多回答

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com