Safeargs library doesnt generate direction class

前端 未结 19 957
孤街浪徒
孤街浪徒 2021-02-01 11:44

I use navigation library and safeargs for passing data. I define argument to fragment like that.



        
19条回答
  •  难免孤独
    2021-02-01 12:24

    Also make sure to use an up to date version. Had the problem, that I had an 1.X version.

    // Navigation
    implementation "androidx.navigation:navigation-fragment-ktx:2.2.1"
    implementation "androidx.navigation:navigation-ui-ktx:2.2.1"
    

    And the args correctely in the nav.xml:

    
        
        
    
    

    Code:

    override fun onItemClicked(category: Category) {
         val action = CategoryFragmentDirections.actionCategoryToProductFragment(products = "myString") // /!\
         view?.findNavController()?.navigate(action)
    }
    

提交回复
热议问题