我想使用导航架构组件.
但我在导入safeargs方面遇到了问题
同步消息:
找不到androidx.navigation:safe-args-gradle-plugin:1.0.0-alpha01.在以下位置进行了搜索:
https://dl.google.com/dl/android/maven2/androidx/navigation/safe-args-gradle-plugin/1.0.0-alpha01/safe-args-gradle-plugin-1.0. 0-alpha01.pom
https://dl.google.com/dl/android/maven2/androidx/navigation/safe-args-gradle-plugin/1.0.0-alpha01/safe-args-gradle-plugin-1.0.0 -alpha01.jar
https://jcenter.bintray.com/androidx/navigation/safe-args-gradle-plugin/1.0.0-alpha01/safe-args-gradle-plugin-1.0.0-alpha01.pom
https:/ /jcenter.bintray.com/androidx/navigation/safe-args-gradle-plugin/1.0.0-alpha01/safe-args-gradle-plugin-1.0.0-alpha01.jar
要求:
项目:
我跟随添加组件到您的项目,但没有解决我的问题.
项目:build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath "androidx.navigation:safe-args-gradle-plugin:1.0.0-alpha01"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) { …Run Code Online (Sandbox Code Playgroud) 当我尝试使用 Safe Args 插件从一个片段跳转到另一个片段时,编译器显示“未解析的引用:VideoFragmentDirections”。我已经设置了安全参数的类路径和依赖项,并且 VideoFragmentArgs 已正确生成。kotlin_version = '1.3.50' navigation-safe-args-gradle-plugin:2.1.0 在我的 xml 中
<fragment
android:id="@+id/nav_home"
android:name="example.ui.home.HomeFragment"
android:label="@string/menu_home"
tools:layout="@layout/fragment_home" >
<action
android:id="@+id/action_nav_home_to_videoFragment"
app:destination="@id/videoFragment"
app:popUpTo="@+id/nav_home"/>
</fragment>
<fragment
android:id="@+id/videoFragment"
android:name="example.ui.videoui.VideoFragment"
android:label="VideoFragment" >
<argument
android:name="id"
app:argType="long"
android:defaultValue="0L" />
</fragment>
Run Code Online (Sandbox Code Playgroud)
在 HomeFragment.ky 中
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
val videoViewModel = ViewModelProviders
.of(this)
.get(HomeViewModel::class.java)
val adapter = video_list.adapter!! as PlaylistAdapter
videoViewModel.videos.observe(this, Observer<List<Video>> {
adapter.submitList(it)
adapter.onItemClickListener = View.OnClickListener { v ->
val viewHolder = v.tag as RecyclerView.ViewHolder
val position = viewHolder.adapterPosition
val id …Run Code Online (Sandbox Code Playgroud)