Skip to content

Instantly share code, notes, and snippets.

@hjiee
Last active September 21, 2019 00:38
Show Gist options
  • Save hjiee/710decd70f05ff3a0314bf24b1dab20d to your computer and use it in GitHub Desktop.
Save hjiee/710decd70f05ff3a0314bf24b1dab20d to your computer and use it in GitHub Desktop.
class ListViewAdapter(
private val layoutResId: Int,
private val items: List<String>
) : BaseAdapter() {
// .. 중략
override fun getView(position: Int, view: View?, parent: ViewGroup?): View? {
var convertView = view
convertView = LayoutInflater.from(parent?.context).inflate(layoutResId, parent, false)
convertView?.tv_item?.text = items[position]
return convertView
}
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
lv_list.adapter = ListViewAdapter(
R.layout.listview_item,
createList()
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment