極簡化版本
class RecycleAdapterReplyInterviewKT(val publicActivity: PublicActivity, val mData: ArrayList<ReplyInterviewItem>, val mItemClick: View.OnClickListener) : RecyclerView.Adapter<RecyclerView.ViewHolder>() { class ViewHolderHeader(view: View) : RecyclerView.ViewHolder(view) { val txtv_reply_interview_text = view.txtv_reply_interview_text } class ViewHolderListItem(view: View) : RecyclerView.ViewHolder(view) { val txtv_reply_interview_item_job_name = view.txtv_reply_interview_item_job_name val txtv_reply_interview_item_comp_name = view.txtv_reply_interview_item_comp_name val txtv_reply_interview_item_date = view.txtv_reply_interview_item_date val btn_reply_interview_not_accept = view.btn_reply_interview_not_accept val btn_reply_interview_accept = view.btn_reply_interview_accept } override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder { var layoutInflater = LayoutInflater.from(parent.context) if (viewType == 1) { return ViewHolderHeader(layoutInflater.inflate(R.layout.item_reply_interview_header, parent, false)) } else { return ViewHolderHeader(layoutInflater.inflate(R.layout.item_reply_interview, parent, false)) } } override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) { if (holder is ViewHolderHeader) { val string_tmp = publicActivity.getString(R.string.reply_interview) val msp = SpannableString(string_tmp) msp.setSpan(ForegroundColorSpan(publicActivity.resources.getColor(R.color.black)), string_tmp.indexOf("「"), string_tmp.indexOf("」"), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE) msp.setSpan(StyleSpan(Typeface.BOLD), string_tmp.indexOf("「"), string_tmp.indexOf("」"), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE) holder.txtv_reply_interview_text.text = msp } else if (holder is ViewHolderListItem) { holder.txtv_reply_interview_item_job_name.text = getItem(position).job_name holder.txtv_reply_interview_item_comp_name.text = getItem(position).comp_name holder.txtv_reply_interview_item_date.text = getItem(position).interview_date holder.btn_reply_interview_accept.setOnClickListener(mItemClick) holder.btn_reply_interview_not_accept.setOnClickListener(mItemClick) } } override fun getItemCount() = mData.size override fun getItemViewType(position: Int) = mData[position].is_header fun getItem(pos: Int) = mData[pos] }