package com.cheng.blzb.ui.fragment.guide.adapter

import android.content.Context
import android.view.View
import android.view.ViewGroup
import android.widget.BaseAdapter
import android.widget.TextView
import com.cheng.blzb.R
import com.cheng.blzb.bean.AreaEntity
import com.cheng.blzb.common.Constants


class GuideItem5CityAdapter(val context: Context, val data: List<AreaEntity>): BaseAdapter() {
    override fun getCount(): Int {
        return data.size
    }

    override fun getItem(position: Int): AreaEntity {
        return data[position]
    }

    override fun getItemId(position: Int): Long {
        return position.toLong()
    }

    override fun getView(position: Int, convertView: View?, parent: ViewGroup?): View {
        val view: View
        val viewHolder: ViewHolder
        if (convertView == null) {
            view = View.inflate(context, R.layout.listitem_guide_item5_city, null)
            viewHolder = ViewHolder(view)
            view.tag = viewHolder
        } else {
            view = convertView
            viewHolder = convertView.tag as ViewHolder
        }
        viewHolder.tvName.typeface = Constants.ysbth
        viewHolder.tvName.text = getItem(position).name
        return view
    }

    inner class ViewHolder(val view: View) {
        val tvName: TextView = view.findViewById(R.id.tv_name)
    }
}