Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/kotlin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 作为函数中的参数扩展指定类的任何对象_Android_Kotlin_Android Recyclerview - Fatal编程技术网

Android 作为函数中的参数扩展指定类的任何对象

Android 作为函数中的参数扩展指定类的任何对象,android,kotlin,android-recyclerview,Android,Kotlin,Android Recyclerview,我正在构建基本活动,在这里我有一个初始化RecyclerView的方法。 我希望这个方法有一个参数,它是一个对象/类,扩展了PagedListAdapter您的参数是class,它是类java.lang.class的实例,但您希望PagedListAdapter的实例如下: protected fun initRecyclerView(mAdapter: PagedListAdapter<out Any, out RecyclerView.ViewHolder>) { if

我正在构建基本活动,在这里我有一个初始化
RecyclerView
的方法。
我希望这个方法有一个参数,它是一个对象/类,扩展了
PagedListAdapter您的参数是
class
,它是类
java.lang.class
的实例,但您希望
PagedListAdapter
的实例如下:

protected fun initRecyclerView(mAdapter: PagedListAdapter<out Any, out RecyclerView.ViewHolder>) {
    if (mRecyclerView?.layoutManager == null)
        mRecyclerView?.layoutManager = component.linearLayoutManager
    if (mRecyclerView?.adapter == null)
        mRecyclerView?.adapter = mAdapter
}
protectedfun initRecyclerView(mAdapter:PagedListAdapter){
if(mRecyclerView?.layoutManager==null)
mRecyclerView?.layoutManager=component.linearLayoutManager
if(mRecyclerView?.adapter==null)
mRecyclerView?.adapter=mAdapter
}

您的参数是
Class
,它是Class
java.lang.Class
的实例,但您希望
PagedListAdapter
的实例如下:

protected fun initRecyclerView(mAdapter: PagedListAdapter<out Any, out RecyclerView.ViewHolder>) {
    if (mRecyclerView?.layoutManager == null)
        mRecyclerView?.layoutManager = component.linearLayoutManager
    if (mRecyclerView?.adapter == null)
        mRecyclerView?.adapter = mAdapter
}
protectedfun initRecyclerView(mAdapter:PagedListAdapter){
if(mRecyclerView?.layoutManager==null)
mRecyclerView?.layoutManager=component.linearLayoutManager
if(mRecyclerView?.adapter==null)
mRecyclerView?.adapter=mAdapter
}
Have look Have look
protected fun initRecyclerView(mAdapter: PagedListAdapter<out Any, out RecyclerView.ViewHolder>) {
    if (mRecyclerView?.layoutManager == null)
        mRecyclerView?.layoutManager = component.linearLayoutManager
    if (mRecyclerView?.adapter == null)
        mRecyclerView?.adapter = mAdapter
}