Overload Resolution Ambiguity error in kotlin

前端 未结 5 484

How do I fix this Overload error, I have Overload Resolution Ambiguity error, I sync it in my project and clean it and rebuild it but it\'s get me bellow error ,I add main

5条回答
  •  -上瘾入骨i
    2021-01-01 09:15

    Building off of Les' answer above, I usually like keeping my naming conventions simple like calling a RecyclerView's id @+id/recyclerView. If I have an Activity called ExampleActivity.java with layout R.layout.activity_example, I don't want to directly import every single view in that layout, I'd rather just import all the views from the layout. So I'd just import the whole file in the activity:

    import kotlinx.android.synthetic.main.activity_example.*
    

    to import all the views from my activity's layout file since I usually access all of them anyways. If your layout file includes other layouts, you'll have to import those layouts separately too. So if i use a header layout included in my activity_example.xml file, i'd import that whole layout file

    import kotlinx.android.synthetic.main.header_layout.*
    

提交回复
热议问题