android - Android导航组件未解析参考
问题描述
我刚刚将平台从 windows 更改为 mac,当我尝试构建我的应用程序时,我收到以下消息:
Unresolved reference. None of the following candidates is applicable because of receiver type mismatch:
public fun `Activity;`.findNavController(viewId: Int): `NavController;` defined in androidx.navigation
public fun `View;`.findNavController(): `NavController;` defined in androidx.navigation
错误在该行:
bSettingsLogout.findNavController().navigate(R.id.authenticationActivity)
在 Windows 上,我使用了较旧的 3.3 canary 版本,但在开发人员网站上,导航组件没有任何变化。
我不确定它是 Mac 还是 Android Studio canary 6 错误。
任何帮助,将不胜感激!
解决方案
findNavController
: 有两种实现
public static NavController findNavController (View view)
,
public static NavController findNavController (Activity activity, int viewId)
但你使用
findNavController()
你缺少所需的参数
推荐阅读
- django - POST 请求导致在 Django 中注销
- css - 如果以下元素是 img,如何设置 img 宽度的样式?
- active-directory - 使用 vb.net 通过 MS Graph 访问 Active Directory 的桌面应用程序
- python - Pandas - 如何识别系列中的“nan”值
- python - 带有嵌套字典的 Python urlencode 不如预期
- c++ - c ++ qt如何在图像上绘制图像
- rust - 如何将 u32 与可以取负值的动态 int 相加?
- reactjs - React.js 中的日期选择器周视图
- azure - Azure 堡垒主机:使用 Active Directory 登录
- typescript - (重新)在 SSR/CSR NextJS 应用程序中正确使用 Apollo 缓存