关于这个模板是Templates里面的附加功能,我这个基本也是不想重复写相同的业务代码.具体添加步骤为
1 这个就是你平常新建类的地方
三图的内容是下边
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME}
#end
import android.content.Context
import android.support.v7.widget.RecyclerView
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import kotlinx.android.synthetic.main.你的布局.view.*
/**
* Created by ${USER}
* date:${DATE}
* 描述:
*/
class ${NAME}(private var context: Context,private var list: ArrayList<String>): RecyclerView.Adapter<${NAME}.ViewHolder>() {
private var mLayoutInflater =LayoutInflater.from(context)
override fun onCreateViewHolder(container: ViewGroup, viewType: Int): ViewHolder {
return ViewHolder(mLayoutInflater.inflate(0,container,false))
}
override fun getItemCount(): Int {
return list.size
}
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
}
class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView)
}