我尝试RecycleView
按ID查找ID时遇到以下错误。
错误:- 类型推断失败:没有足够的信息来推断参数T
码:
class FirstRecycleViewExample : AppCompatActivity() {
val data = arrayListOf<String>()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.first_recycleview)
val recycler_view = findViewById(R.id.recycler_view) as RecyclerView ///IN THIS LINE I AM GETTING THE ERROR
data.add("First Data")
data.add("Second Data")
data.add("Third Data")
data.add("Forth Data")
data.add("Fifth Data")
//creating our adapter
val adapter = CustomRecycleAdapter(data)
//now adding the adapter to recyclerview
recycler_view.adapter = adapter
}
}
<>
在使用它时仅使用菱形运算符,因此它给出了错误。